diff --git a/flake.nix b/flake.nix index 871efd5..509a05b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,8 @@ { outputs = { self, nixpkgs }: { - nixosModule = import ./.; + nixosModule = { ... }: { + imports = [ ./. ]; + config = { sconfig.flakes.enable = true; }; + }; }; } diff --git a/modules/cli.nix b/modules/cli.nix index badb63c..2b1484f 100644 --- a/modules/cli.nix +++ b/modules/cli.nix @@ -8,18 +8,6 @@ let "-git-assume-unchanged-size 0" ]; - rebuild-scripts = (map - (x: (pkgs.writeShellScriptBin "sc-${builtins.head x}" "nixos-rebuild ${lib.concatStringsSep " " (builtins.tail x)}")) - [ - [ "switch" "switch" ] - [ "build" "build" ] - [ "boot" "boot" ] - [ "switch-upgrade" "switch" "--recreate-lock-file" "--refresh" ] - [ "build-upgrade" "build" "--recreate-lock-file" "--refresh" ] - [ "boot-upgrade" "boot" "--recreate-lock-file" "--refresh" ] - ] - ); - in { environment.systemPackages = with pkgs; [ @@ -78,7 +66,7 @@ in echo "$(git ls-remote https://github.com/NixOS/nixpkgs.git "$branch" | cut -f1) latest available" echo '') - ] ++ rebuild-scripts; + ]; environment.variables.EDITOR = "vim"; diff --git a/modules/flakes.nix b/modules/flakes.nix index 426aefe..d938499 100644 --- a/modules/flakes.nix +++ b/modules/flakes.nix @@ -3,12 +3,35 @@ let cfg = config.sconfig.flakes; in { - options.sconfig.flakes = lib.mkEnableOption "Enable Flakes"; + options.sconfig.flakes = { + enable = lib.mkEnableOption "Enable Flakes"; + rebuildPath = lib.mkOption { + default = "/etc/nixos"; + type = lib.types.str; + description = "Flake to use when running nixos-rebuild helper scripts"; + }; + }; + + config = lib.mkIf cfg.enable { - config = lib.mkIf cfg { nix.package = pkgs.nixFlakes; nix.extraOptions = '' experimental-features = nix-command flakes ''; + + environment.systemPackages = map + (x: (pkgs.writeShellScriptBin + "sc-${builtins.head x}" + "nixos-rebuild ${lib.concatStringsSep " " (builtins.tail x)} --flake ${cfg.rebuildPath}" + )) + [ + [ "switch" "switch" ] + [ "build" "build" ] + [ "boot" "boot" ] + [ "switch-upgrade" "switch" "--recreate-lock-file" "--refresh" ] + [ "build-upgrade" "build" "--recreate-lock-file" "--refresh" ] + [ "boot-upgrade" "boot" "--recreate-lock-file" "--refresh" ] + ]; + }; }