diff options
| author | seth <[email protected]> | 2024-10-16 21:18:46 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-10-16 23:23:33 -0400 |
| commit | 19b64bed1e31489de83f0c7d1b0ec1e77e3f7c49 (patch) | |
| tree | ab2d101836db1d44f09996a9bea7469dfe2ec80d /templates/standard/flake.nix | |
| parent | 43d30b3ea28ab03a2e6da5101dc2b84918f18c51 (diff) | |
templates: cleanup
Diffstat (limited to 'templates/standard/flake.nix')
| -rw-r--r-- | templates/standard/flake.nix | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/templates/standard/flake.nix b/templates/standard/flake.nix new file mode 100644 index 0000000..9c80e4b --- /dev/null +++ b/templates/standard/flake.nix @@ -0,0 +1,69 @@ +{ + description = ""; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = + { self, nixpkgs }: + let + inherit (nixpkgs) lib; + + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + forAllSystems = lib.genAttrs systems; + nixpkgsFor = nixpkgs.legacyPackages; + in + { + checks = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + + mkCheck = + name: deps: script: + pkgs.runCommand name { nativeBuildInputs = deps; } script; + in + { + nixfmt = mkCheck "check-nixfmt" [ pkgs.nixfmt-rfc-style ] '' + nixfmt --check ${self} + + touch $out + ''; + } + ); + + devShells = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.mkShell { + packages = [ pkgs.bash ]; + + inputsFrom = [ self.packages.${system}.hello ]; + }; + } + ); + + formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); + + packages = forAllSystems ( + system: + let + pkgs = import ./default.nix { + pkgs = nixpkgsFor.${system}; + }; + + isAvailable = lib.meta.availableOn { inherit system; }; + pkgs' = lib.filterAttrs (_: isAvailable) pkgs; + in + pkgs // { default = pkgs'.hello or pkgs.emptyFile; } + ); + }; +} |
