mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 12:51:34 +01:00
Improve nixos-rebuild with nix-helper
This commit is contained in:
parent
7adfa40f4d
commit
d5729dc447
7 changed files with 70 additions and 5 deletions
21
flake.lock
generated
21
flake.lock
generated
|
|
@ -20,6 +20,26 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nh": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710573382,
|
||||
"narHash": "sha256-oGPasBk516A6pNE7iBEOmtrNsbqd+frR7O+z9lr1cLw=",
|
||||
"owner": "viperML",
|
||||
"repo": "nh",
|
||||
"rev": "60c019a930e1718f1c5b6638f16dc221bf667d61",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "viperML",
|
||||
"repo": "nh",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-index-database": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
|
@ -75,6 +95,7 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"home-manager": "home-manager",
|
||||
"nh": "nh",
|
||||
"nix-index-database": "nix-index-database",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"sops-nix": "sops-nix"
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@
|
|||
url = "github:Mic92/sops-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
nh = {
|
||||
url = "github:viperML/nh";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {nixpkgs, ...} @ inputs: let
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
networking.hostName = "dell-laptop";
|
||||
|
||||
environment.sessionVariables.FLAKE = "/home/seb/Projects/nixos/my-config";
|
||||
|
||||
myConfig = {
|
||||
boot-loader.systemd-boot.enable = true;
|
||||
|
||||
|
|
@ -24,6 +26,7 @@
|
|||
sops.enable = true;
|
||||
auto-cpufreq.enable = true;
|
||||
doas.enable = false;
|
||||
nix-helper.enable = true;
|
||||
};
|
||||
|
||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
osConfig,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myConfig.shell;
|
||||
|
|
@ -9,12 +10,25 @@ in {
|
|||
bash.enable = lib.mkEnableOption "";
|
||||
zsh.enable = lib.mkEnableOption "";
|
||||
starship.enable = lib.mkEnableOption "";
|
||||
nixAliases.enable = lib.mkEnableOption "";
|
||||
nixAliases = {
|
||||
enable = lib.mkEnableOption "";
|
||||
nix-helper.enable = lib.mkEnableOption "";
|
||||
};
|
||||
improvedCommands.enable = lib.mkEnableOption "";
|
||||
direnv.enable = lib.mkEnableOption "";
|
||||
};
|
||||
|
||||
config = {
|
||||
assertions = [
|
||||
{
|
||||
assertion =
|
||||
if cfg.nixAliases.nix-helper.enable
|
||||
then osConfig.myConfig.nix-helper.enable
|
||||
else true;
|
||||
message = "The nix-helper has to be enabled on the OS level.";
|
||||
}
|
||||
];
|
||||
|
||||
programs.bash.enable = cfg.bash.enable;
|
||||
|
||||
programs.zsh.enable = cfg.zsh.enable;
|
||||
|
|
@ -35,10 +49,14 @@ in {
|
|||
|
||||
home.shellAliases = let
|
||||
nixAliases = lib.mkIf cfg.nixAliases.enable {
|
||||
nrs = "sudo nixos-rebuild switch";
|
||||
nrb = "sudo nixos-rebuild boot";
|
||||
nr =
|
||||
if cfg.nixAliases.nix-helper.enable
|
||||
then "nh os"
|
||||
else "sudo nixos-rebuild --flake $FLAKE";
|
||||
nrs = "nr switch";
|
||||
nrt = "nr test";
|
||||
nrb = "nr boot";
|
||||
nrrb = "nrb && reboot";
|
||||
nrt = "sudo nixos-rebuild test";
|
||||
nu = "sudo nix flake update";
|
||||
};
|
||||
commandAliases = lib.mkIf cfg.improvedCommands.enable {
|
||||
|
|
|
|||
|
|
@ -15,5 +15,6 @@
|
|||
./dm.nix
|
||||
./sound.nix
|
||||
./boot-loader.nix
|
||||
./nix-helper.nix
|
||||
];
|
||||
}
|
||||
|
|
|
|||
14
modules/system/nix-helper.nix
Normal file
14
modules/system/nix-helper.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
inputs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
imports = [inputs.nh.nixosModules.default];
|
||||
|
||||
options.myConfig.nix-helper.enable = lib.mkEnableOption "";
|
||||
|
||||
config = lib.mkIf config.myConfig.nix-helper.enable {
|
||||
nh.enable = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -5,7 +5,10 @@
|
|||
shell = {
|
||||
bash.enable = true;
|
||||
starship.enable = true;
|
||||
nixAliases.enable = true;
|
||||
nixAliases = {
|
||||
enable = true;
|
||||
nix-helper.enable = true;
|
||||
};
|
||||
improvedCommands.enable = true;
|
||||
direnv.enable = true;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue