nixos-config/modules/flakes.nix

38 lines
1,013 B
Nix
Raw Normal View History

2021-01-17 22:08:34 +00:00
{ config, pkgs, lib, ... }:
let
cfg = config.sconfig.flakes;
in
{
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 {
2021-01-17 22:08:34 +00:00
2021-04-01 03:43:23 +00:00
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" ]
];
2021-01-17 22:08:34 +00:00
};
}