diff options
| -rw-r--r-- | templates/full/default.nix | 22 | ||||
| -rw-r--r-- | templates/full/flake.nix | 19 | ||||
| -rw-r--r-- | templates/full/nix/default.nix | 17 | ||||
| -rw-r--r-- | templates/full/nix/dev.nix | 12 | ||||
| -rw-r--r-- | templates/full/nix/packages.nix | 24 | ||||
| -rw-r--r-- | templates/full/nix/pkgs/default.nix | 24 | ||||
| -rw-r--r-- | templates/full/nix/pkgs/hello.nix | 25 |
7 files changed, 56 insertions, 87 deletions
diff --git a/templates/full/default.nix b/templates/full/default.nix index c7d0c26..5804660 100644 --- a/templates/full/default.nix +++ b/templates/full/default.nix @@ -1,14 +1,10 @@ -( - 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 = ./.;} -) +(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 index 3976e91..a98971a 100644 --- a/templates/full/flake.nix +++ b/templates/full/flake.nix @@ -16,9 +16,11 @@ pre-commit = { url = "github:cachix/pre-commit-hooks.nix"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.nixpkgs-stable.follows = "nixpkgs"; - inputs.flake-compat.follows = "compat"; + inputs = { + nixpkgs.follows = "nixpkgs"; + nixpkgs-stable.follows = "nixpkgs"; + flake-compat.follows = "compat"; + }; }; }; @@ -30,7 +32,16 @@ parts.lib.mkFlake {inherit inputs;} { imports = [ pre-commit.flakeModule - ./nix + + ./nix/dev.nix + ./nix/packages.nix + ]; + + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" ]; }; } diff --git a/templates/full/nix/default.nix b/templates/full/nix/default.nix deleted file mode 100644 index 2033702..0000000 --- a/templates/full/nix/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -_: { - imports = [ - ./dev.nix - ./pkgs - ]; - - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - - perSystem = {pkgs, ...}: { - formatter = pkgs.alejandra; - }; -} diff --git a/templates/full/nix/dev.nix b/templates/full/nix/dev.nix index 508e3d6..e3197ff 100644 --- a/templates/full/nix/dev.nix +++ b/templates/full/nix/dev.nix @@ -1,9 +1,10 @@ -{self, ...}: { +{ perSystem = { - config, pkgs, + config, + self', ... - } @ args: { + }: { pre-commit = { settings.hooks = { alejandra.enable = true; @@ -16,13 +17,16 @@ devShells = { default = pkgs.mkShell { shellHook = config.pre-commit.installationScript; + packages = with pkgs; [ - self.formatter.${args.system} + self'.formatter deadnix nil statix ]; }; }; + + formatter = pkgs.alejandra; }; } diff --git a/templates/full/nix/packages.nix b/templates/full/nix/packages.nix new file mode 100644 index 0000000..8b23ea7 --- /dev/null +++ b/templates/full/nix/packages.nix @@ -0,0 +1,24 @@ +{self, ...}: { + flake.overlays.default = _: prev: { + foo = prev.callPackage ./derivation.nix {inherit self;}; + }; + + perSystem = { + lib, + pkgs, + ... + }: { + package = let + fixup = lib.filterAttrs ( + _: v: + builtins.elem (v.meta.platforms or []) && !(v.meta.broken or false) + ); + + unfiltered = lib.fix (final: self.overlays.default final pkgs); + pkgs' = fixup unfiltered; + in { + inherit (pkgs') foo; + default = pkgs'.foo; + }; + }; +} diff --git a/templates/full/nix/pkgs/default.nix b/templates/full/nix/pkgs/default.nix deleted file mode 100644 index 2bc2a93..0000000 --- a/templates/full/nix/pkgs/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - self, - inputs, - ... -}: let - version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; - - filterPkgs = - inputs.nixpkgs.lib.filterAttrs (_: v: - builtins.elem (v.meta.platforms or []) && !(v.meta.broken or false)); - - packageFn = pkgs: { - hello = pkgs.callpackage ./hello.nix {inherit self version;}; - }; -in { - flake.overlays = _: prev: (packageFn prev); - - perSystem = {pkgs, ...}: { - packages = let - p = filterPkgs (packageFn pkgs); - in - p // {default = p.hello;}; - }; -} diff --git a/templates/full/nix/pkgs/hello.nix b/templates/full/nix/pkgs/hello.nix deleted file mode 100644 index 1e2ec12..0000000 --- a/templates/full/nix/pkgs/hello.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - lib, - stdenv, - self, - version, - ... -}: -stdenv.mkDerivation { - pname = "hello"; - inherit version; - - src = lib.cleanSource self; - - installPhase = '' - echo "hi" > $out - ''; - - meta = with lib; { - description = ""; - homepage = ""; - license = licenses.mit; - maintainers = [maintainers.getchoo]; - platforms = platforms.linux; - }; -} |
