diff options
| author | seth <[email protected]> | 2024-07-22 03:27:22 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-07-22 03:27:22 -0400 |
| commit | cec5413fcc0ca6b2049efe5a44f3b3fbe6f5f0a1 (patch) | |
| tree | cd34804b4c674a88f1fdbf03a8c4c9a7abe158ef /templates/basic/flake.nix | |
| parent | 8160024f34c51057c8c2956113da6a3974d931d6 (diff) | |
templates: modernize
Diffstat (limited to 'templates/basic/flake.nix')
| -rw-r--r-- | templates/basic/flake.nix | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/templates/basic/flake.nix b/templates/basic/flake.nix index 1840cb1..f1c84df 100644 --- a/templates/basic/flake.nix +++ b/templates/basic/flake.nix @@ -2,12 +2,13 @@ description = ""; inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; outputs = - { self, nixpkgs, ... }: + { self, nixpkgs }: let + inherit (nixpkgs) lib; systems = [ "x86_64-linux" "aarch64-linux" @@ -15,31 +16,55 @@ "aarch64-darwin" ]; - forAllSystems = fn: nixpkgs.lib.genAttrs systems (sys: fn nixpkgs.legacyPackages.${sys}); - version = self.shortRev or self.dirtyShortRev or "unknown"; + forAllSystems = fn: lib.genAttrs systems; + nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); in { + checks = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + in + { + nixfmt = pkgs.runCommand "check-nixfmt" '' + cd ${self} + + echo "Running nixfmt..." + ${lib.getExe self.formatter.${system}}--check . + + touch $out + ''; + } + ); + devShells = forAllSystems ( - { pkgs, system, ... }: + system: + let + pkgs = nixpkgsFor.${system}; + in { default = pkgs.mkShell { - packages = with pkgs; [ bash ]; + packages = [ pkgs.bash ]; inputsFrom = [ self.packages.${system}.hello ]; }; } ); - formatter = forAllSystems (pkgs: pkgs.alejandra); + formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); packages = forAllSystems ( - { pkgs, system, ... }: - { - hello = pkgs.callPackage ./. { inherit version; }; - default = self.packages.${system}.hello; - } - ); + system: + let + pkgs = import ./. { + inherit system nixpkgs lib; + pkgs = nixpkgsFor.${system}; + }; - overlays.default = _: prev: { hello = prev.callPackage ./. { inherit version; }; }; + isAvailable = lib.meta.availableOn { inherit system; }; + pkgs' = lib.filterAttrs (_: isAvailable) pkgs; + in + pkgs // { default = pkgs'.hello; } + ); }; } |
