summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/basic/flake.nix75
-rw-r--r--templates/full/default.nix14
-rw-r--r--templates/full/flake.nix26
-rw-r--r--templates/full/nix/default.nix6
-rw-r--r--templates/full/nix/flake/default.nix43
-rw-r--r--templates/full/nix/packages/default.nix23
-rw-r--r--templates/full/nix/packages/hello.nix29
7 files changed, 216 insertions, 0 deletions
diff --git a/templates/basic/flake.nix b/templates/basic/flake.nix
new file mode 100644
index 0000000..2c638b2
--- /dev/null
+++ b/templates/basic/flake.nix
@@ -0,0 +1,75 @@
+{
+ description = "";
+
+ inputs = {
+ nixpkgs.url = "nixpkgs/nixos-unstable";
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ ...
+ }: let
+ version = builtins.substring 0 8 self.lastModifiedDate;
+
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ forAllSystems = nixpkgs.lib.genAttrs systems;
+ nixpkgsFor = forAllSystems (system:
+ import nixpkgs {
+ inherit system;
+ overlays = [self.overlays.default];
+ });
+
+ packageFn = pkgs: let
+ inherit (pkgs.lib) licenses maintainers platforms;
+ in {
+ hello = pkgs.stdenv.mkDerivation rec {
+ pname = "hello";
+ inherit version;
+
+ src = builtins.path {
+ name = "${pname}-src";
+ path = ./.;
+ };
+
+ installPhase = ''
+ echo "hi" > $out
+ '';
+
+ meta = {
+ description = "";
+ homepage = "";
+ license = licenses.mit;
+ maintainers = [maintainers.getchoo];
+ platforms = platforms.linux;
+ };
+ };
+ };
+ in {
+ devShells = forAllSystems (s: let
+ pkgs = nixpkgsFor.${s};
+ inherit (pkgs) mkShell;
+ in {
+ default = mkShell {
+ packages = with pkgs; [
+ bash
+ ];
+ };
+ });
+
+ formatter = forAllSystems (s: nixpkgsFor.${s}.alejandra);
+
+ packages = forAllSystems (s: rec {
+ inherit (nixpkgsFor.${s}) hello;
+ default = hello;
+ });
+
+ overlays.default = final: _: packageFn final;
+ };
+}
diff --git a/templates/full/default.nix b/templates/full/default.nix
new file mode 100644
index 0000000..c7d0c26
--- /dev/null
+++ b/templates/full/default.nix
@@ -0,0 +1,14 @@
+(
+ import
+ (
+ let
+ lock = builtins.fromJSON (builtins.readFile ./flake.lock);
+ in
+ fetchTarball {
+ url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
+ sha256 = lock.nodes.flake-compat.locked.narHash;
+ }
+ )
+ {src = ./.;}
+)
+.defaultNix
diff --git a/templates/full/flake.nix b/templates/full/flake.nix
new file mode 100644
index 0000000..c745441
--- /dev/null
+++ b/templates/full/flake.nix
@@ -0,0 +1,26 @@
+{
+ description = "";
+
+ inputs = {
+ nixpkgs.url = "nixpkgs/nixos-unstable";
+ flake-compat = {
+ url = "github:edolstra/flake-compat";
+ flake = false;
+ };
+ flake-parts = {
+ url = "github:hercules-ci/flake-parts";
+ inputs.nixpkgs-lib.follows = "nixpkgs";
+ };
+ pre-commit-hooks = {
+ url = "github:cachix/pre-commit-hooks.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ inputs.nixpkgs-stable.follows = "nixpkgs";
+ inputs.flake-compat.follows = "flake-compat";
+ };
+ };
+
+ outputs = inputs:
+ inputs.flake-parts.lib.mkFlake
+ {inherit inputs;}
+ {imports = [./nix];};
+}
diff --git a/templates/full/nix/default.nix b/templates/full/nix/default.nix
new file mode 100644
index 0000000..4b52983
--- /dev/null
+++ b/templates/full/nix/default.nix
@@ -0,0 +1,6 @@
+_: {
+ imports = [
+ ./packages
+ ./flake
+ ];
+}
diff --git a/templates/full/nix/flake/default.nix b/templates/full/nix/flake/default.nix
new file mode 100644
index 0000000..4402a16
--- /dev/null
+++ b/templates/full/nix/flake/default.nix
@@ -0,0 +1,43 @@
+{
+ inputs,
+ self,
+ ...
+}: {
+ perSystem = {
+ pkgs,
+ system,
+ ...
+ }: {
+ checks = {
+ pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
+ src = builtins.path {
+ name = "flake-src";
+ path = ../../.;
+ };
+
+ hooks = {
+ alejandra.enable = true;
+ deadnix.enable = true;
+ nil.enable = true;
+ statix.enable = true;
+ };
+ };
+ };
+
+ devShells = let
+ inherit (pkgs) mkShell;
+ in {
+ default = mkShell {
+ inherit (self.checks.${system}.pre-commit-check) shellHook;
+ packages = with pkgs; [
+ alejandra
+ deadnix
+ nil
+ statix
+ ];
+ };
+ };
+
+ formatter = pkgs.alejandra;
+ };
+}
diff --git a/templates/full/nix/packages/default.nix b/templates/full/nix/packages/default.nix
new file mode 100644
index 0000000..78e10db
--- /dev/null
+++ b/templates/full/nix/packages/default.nix
@@ -0,0 +1,23 @@
+{self, ...}: let
+ version = builtins.substring 0 8 self.lastModifiedDate;
+
+ packageFn = pkgs: {
+ hello = pkgs.callPackage ./hello.nix {inherit version;};
+ };
+in {
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ flake.overlays = final: _: packageFn final;
+
+ perSystem = {pkgs, ...}: {
+ packages = let
+ p = packageFn pkgs;
+ in
+ p // {default = p.hello;};
+ };
+}
diff --git a/templates/full/nix/packages/hello.nix b/templates/full/nix/packages/hello.nix
new file mode 100644
index 0000000..30cfc8d
--- /dev/null
+++ b/templates/full/nix/packages/hello.nix
@@ -0,0 +1,29 @@
+{
+ lib,
+ stdenv,
+ version,
+ ...
+}: let
+ inherit (lib) licenses maintainers platforms;
+in
+ stdenv.mkDerivation rec {
+ pname = "hello";
+ inherit version;
+
+ src = builtins.path {
+ name = "${pname}-src";
+ path = ./.;
+ };
+
+ installPhase = ''
+ echo "hi" > $out
+ '';
+
+ meta = {
+ description = "";
+ homepage = "";
+ license = licenses.mit;
+ maintainers = [maintainers.getchoo];
+ platforms = platforms.linux;
+ };
+ }