diff options
| author | seth <[email protected]> | 2023-11-03 14:35:29 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2023-11-03 14:35:29 -0400 |
| commit | ddfdbeae737b8bda7688f1eb878ba413e2793c0a (patch) | |
| tree | 2a63bbedc1ea2710dca28c244a32f34c245555aa /templates | |
| parent | 248d7050e0e861ffc9baa4c21d8f46c97124cd56 (diff) | |
templates/nixos: add justfile and dev shell
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/nixos/flake.nix | 22 | ||||
| -rw-r--r-- | templates/nixos/justfile | 31 |
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 |
