summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/nixos/flake.nix22
-rw-r--r--templates/nixos/justfile31
2 files changed, 52 insertions, 1 deletions
diff --git a/templates/nixos/flake.nix b/templates/nixos/flake.nix
index 7c3e15d..a8c2e09 100644
--- a/templates/nixos/flake.nix
+++ b/templates/nixos/flake.nix
@@ -9,11 +9,31 @@
};
};
- outputs = {nixpkgs, ...} @ inputs: {
+ outputs = {nixpkgs, ...} @ inputs: let
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ forAllSystems = fn: nixpkgs.lib.genAttrs systems (sys: fn nixpkgs.legacyPackages.${sys});
+ in {
nixosConfigurations."myHostname" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [./configuration.nix];
specialArgs = {inherit inputs;};
};
+
+ devShells = forAllSystems (pkgs: {
+ default = pkgs.mkShell {
+ packages = with pkgs; [
+ just
+ fzf
+ ];
+ };
+ });
+
+ formatter = forAllSystems (pkgs: pkgs.alejandra);
};
}
diff --git a/templates/nixos/justfile b/templates/nixos/justfile
new file mode 100644
index 0000000..4964484
--- /dev/null
+++ b/templates/nixos/justfile
@@ -0,0 +1,31 @@
+alias b := build
+alias dr := dry-run
+alias sw := switch
+alias t := test
+alias u := update
+
+rebuildArgs := "--verbose"
+rebuild := if os() == "macos" { "darwin-rebuild" } else { "nixos-rebuild" }
+asRoot := if os() == "linux" { "true" } else { "false" }
+
+default:
+ @just --choose
+
+[private]
+rebuild subcmd root="false":
+ {{ if root == "true" { "sudo " } else { "" } }}{{ rebuild }} {{ subcmd }} {{ rebuildArgs }} --flake .
+
+build:
+ @just rebuild build
+
+dry-run:
+ @just rebuild dry-run
+
+switch:
+ @just rebuild switch {{ asRoot }}
+
+test:
+ @just rebuild test {{ asRoot }}
+
+update:
+ nix flake update --commit-lock-file