summaryrefslogtreecommitdiff
path: root/templates/standard
diff options
context:
space:
mode:
Diffstat (limited to 'templates/standard')
-rw-r--r--templates/standard/default.nix12
-rw-r--r--templates/standard/flake.nix69
2 files changed, 81 insertions, 0 deletions
diff --git a/templates/standard/default.nix b/templates/standard/default.nix
new file mode 100644
index 0000000..b782208
--- /dev/null
+++ b/templates/standard/default.nix
@@ -0,0 +1,12 @@
+{
+ pkgs ? import nixpkgs {
+ inherit system;
+ config = { };
+ overlays = [ ];
+ },
+ nixpkgs ? <nixpkgs>,
+ system ? builtins.currentSystem,
+}:
+{
+ inherit (pkgs) hello;
+}
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; }
+ );
+ };
+}