messed with disko and zfs, removed direnv module as it got upstreamed

This commit is contained in:
Gerg-L 2023-07-16 15:33:43 -04:00
parent 3e0398f799
commit 29fa4dff1d
11 changed files with 109 additions and 297 deletions

View file

@ -1,6 +1,7 @@
_: { _: {
pkgs, pkgs,
config, config,
lib,
... ...
}: { }: {
local = { local = {
@ -15,13 +16,13 @@ _: {
enable = true; enable = true;
kmscon.enable = true; kmscon.enable = true;
}; };
allowedUnfree = [
"nvidia-x11"
"nvidia-persistenced"
"steam"
"steam-original"
];
}; };
nixpkgs.allowedUnfree = [
"nvidia-x11"
"nvidia-persistenced"
"steam"
"steam-original"
];
environment = { environment = {
systemPackages = builtins.attrValues { systemPackages = builtins.attrValues {
inherit inherit
@ -38,8 +39,8 @@ _: {
; ;
}; };
etc = { etc = {
"jdks/17".source = "${pkgs.openjdk17}/bin"; "jdks/17".source = lib.getBin pkgs.openjdk17;
"jdks/8".source = "${pkgs.openjdk8}/bin"; "jdks/8".source = lib.getBin pkgs.openjdk8;
}; };
}; };
networking = { networking = {

View file

@ -1,5 +1,4 @@
{disko, ...}: {disks ? [], ...}: { {disko, ...}: {
dummyvalue = {inherit disks;};
imports = [disko.nixosModules.disko]; imports = [disko.nixosModules.disko];
disko.devices = { disko.devices = {
disk.nvme0n1 = { disk.nvme0n1 = {

View file

@ -1,6 +1,7 @@
{nvim-flake, ...}: { {nvim-flake, ...}: {
pkgs, pkgs,
config, config,
lib,
... ...
}: { }: {
local = { local = {
@ -18,6 +19,11 @@
enable = true; enable = true;
kmscon.enable = true; kmscon.enable = true;
}; };
allowedUnfree = [
"nvidia-x11"
"steam"
"steam-original"
];
}; };
boot.binfmt.emulatedSystems = ["aarch64-linux"]; boot.binfmt.emulatedSystems = ["aarch64-linux"];
hardware.nvidia = { hardware.nvidia = {
@ -31,11 +37,6 @@
videoDrivers = ["nvidia" "amdgpu"]; videoDrivers = ["nvidia" "amdgpu"];
}; };
nixpkgs.allowedUnfree = [
"nvidia-x11"
"steam"
"steam-original"
];
programs.direnv = { programs.direnv = {
enable = true; enable = true;
loadInNixShell = false; loadInNixShell = false;
@ -67,8 +68,8 @@
inherit (nvim-flake.packages.${pkgs.system}) neovim; inherit (nvim-flake.packages.${pkgs.system}) neovim;
}; };
etc = { etc = {
"jdks/17".source = "${pkgs.openjdk17}/bin"; "jdks/17".source = lib.getBin pkgs.openjdk17;
"jdks/8".source = "${pkgs.openjdk8}/bin"; "jdks/8".source = lib.getBin pkgs.openjdk8;
}; };
shellAliases.lint = "deadnix -e && statix fix && alejandra ./"; shellAliases.lint = "deadnix -e && statix fix && alejandra ./";
}; };

View file

@ -1,119 +1,70 @@
{disko, ...}: {disks ? [], ...}: { {disko, ...}: {lib, ...}: let
dummyvalue = {inherit disks;}; disks = [
"nvme-SHPP41-500GM_SSB4N6719101A4N22"
"nvme-SHPP41-500GM_SSB4N6719101A4N0E"
];
in {
imports = [disko.nixosModules.disko]; imports = [disko.nixosModules.disko];
disko.devices = { disko.devices = {
disk = { disk = lib.mkMerge (map (x: {
nvme0 = { ${x} = {
type = "disk"; type = "disk";
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N22";
content = { device = "/dev/disk/by-id/${x}";
type = "table"; content = {
format = "gpt"; type = "table";
partitions = [ format = "gpt";
{ partitions = [
name = "boot"; {
start = "0"; name = "boot";
end = "1M"; start = "0";
part-type = "primary"; end = "1M";
flags = ["bios_grub"]; part-type = "primary";
} flags = ["bios_grub"];
{ }
name = "ESP"; {
start = "1M"; name = "ESP";
end = "1G"; start = "1M";
bootable = true; end = "1G";
content = { bootable = true;
type = "filesystem"; content = {
format = "vfat"; type = "filesystem";
mountpoint = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N22"; format = "vfat";
}; mountpoint = "/boot/efis/${x}";
} };
{ }
name = "zfsboot"; {
start = "1G"; name = "zfsboot";
end = "5G"; start = "1G";
content = { end = "5G";
type = "zfs"; content = {
pool = "bpool"; type = "zfs";
}; pool = "bpool";
} };
{ }
name = "swap"; {
start = "5G"; name = "swap";
end = "21G"; start = "5G";
content = { end = "21G";
type = "swap"; content = {
randomEncryption = true; type = "swap";
}; randomEncryption = true;
} };
{ }
name = "zfsroot"; {
start = "21G"; name = "zfsroot";
end = "100%"; start = "21G";
content = { end = "100%";
type = "zfs"; content = {
pool = "rpool"; type = "zfs";
}; pool = "rpool";
} };
]; }
];
};
}; };
}; })
nvme1 = { disks);
type = "disk";
device = "/dev/disk/by-id/nvme-SHPP41-500GM_SSB4N6719101A4N0E";
content = {
type = "table";
format = "gpt";
partitions = [
{
name = "BIOS";
start = "0";
end = "1M";
part-type = "primary";
flags = ["bios_grub"];
}
{
name = "ESP";
start = "1M";
end = "1G";
bootable = true;
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot/efis/nvme-SHPP41-500GM_SSB4N6719101A4N0E";
};
}
{
name = "zfsboot";
start = "1G";
end = "5G";
content = {
type = "zfs";
pool = "bpool";
};
}
{
name = "swap";
start = "5G";
end = "21G";
content = {
type = "swap";
randomEncryption = true;
};
}
{
name = "zfsroot";
start = "21G";
end = "100%";
content = {
type = "zfs";
pool = "rpool";
};
}
];
};
};
};
zpool = { zpool = {
rpool = { rpool = {
type = "zpool"; type = "zpool";
@ -139,26 +90,31 @@
type = "zfs_fs"; type = "zfs_fs";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/"; mountpoint = "/";
postCreateHook = "zfs snapshot root@empty";
}; };
"nix" = { "nix" = {
type = "zfs_fs"; type = "zfs_fs";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/nix"; mountpoint = "/nix";
postCreateHook = "zfs snapshot nix@empty";
}; };
"var" = { "var" = {
type = "zfs_fs"; type = "zfs_fs";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/var"; mountpoint = "/var";
postCreateHook = "zfs snapshot var@empty";
}; };
"persist" = { "persist" = {
type = "zfs_fs"; type = "zfs_fs";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/persist"; mountpoint = "/persist";
postCreateHook = "zfs snapshot persist@empty";
}; };
"home" = { "home" = {
type = "zfs_fs"; type = "zfs_fs";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/home"; mountpoint = "/home";
postCreateHook = "zfs snapshot home@empty";
}; };
}; };
}; };
@ -185,6 +141,7 @@
type = "zfs_fs"; type = "zfs_fs";
options.mountpoint = "legacy"; options.mountpoint = "legacy";
mountpoint = "/boot"; mountpoint = "/boot";
postCreateHook = "zfs snapshot boot@empty";
}; };
}; };
}; };

View file

@ -3,7 +3,7 @@
ex = spicePkgs.extensions; ex = spicePkgs.extensions;
in { in {
imports = [spicetify-nix.nixosModule]; imports = [spicetify-nix.nixosModule];
nixpkgs.allowedUnfree = ["spotify"]; local.allowedUnfree = ["spotify"];
programs.spicetify = { programs.spicetify = {
enable = true; enable = true;
enabledExtensions = [ enabledExtensions = [

View file

@ -10,13 +10,10 @@ _: {
"L /etc/nixos/flake.nix - - - - /home/gerg/Projects/nixos/flake.nix" "L /etc/nixos/flake.nix - - - - /home/gerg/Projects/nixos/flake.nix"
]; ];
#create machine-id for spotify #create machine-id for spotify
environment.etc = { environment.etc."machine-id".text = "b6431c2851094770b614a9cfa78fb6ea";
"machine-id".text = "b6431c2851094770b614a9cfa78fb6ea";
};
#make sure the sopskey is found #make sure the sopskey is found
sops.age.sshKeyPaths = lib.mkForce ["/persist/ssh/ssh_host_ed25519_key"]; sops.age.sshKeyPaths = lib.mkForce ["/persist/ssh/ssh_host_ed25519_key"];
fileSystems."/persist".neededForBoot = true; fileSystems."/persist".neededForBoot = true;
boot = { boot = {
zfs = { zfs = {
devNodes = "/dev/disk/by-id/"; devNodes = "/dev/disk/by-id/";
@ -33,6 +30,13 @@ _: {
availableKernelModules = ["hid_generic"]; availableKernelModules = ["hid_generic"];
#wipe / and /var on boot #wipe / and /var on boot
postDeviceCommands = lib.mkAfter '' postDeviceCommands = lib.mkAfter ''
#destroy last snapshot
zfs destroy rpool/root@lastboot
zfs destroy rpool/var@lastboot
#create new snapshot
zfs snapshot rpool/root@lastboot
zfs snapshot rpool/var@lastboot
#wipe everything
zfs rollback -r rpool/root@empty zfs rollback -r rpool/root@empty
zfs rollback -r rpool/var@empty zfs rollback -r rpool/var@empty
''; '';
@ -62,9 +66,6 @@ _: {
} }
]; ];
splashImage = null; splashImage = null;
extraConfig = ''
GRUB_TIMEOUT_STYLE=hidden
'';
}; };
}; };
}; };

View file

@ -1,5 +1,4 @@
{disko, ...}: {disks ? [], ...}: { {disko, ...}: {
dummyvalue = {inherit disks;};
imports = [disko.nixosModules.disko]; imports = [disko.nixosModules.disko];
disko.devices = { disko.devices = {
disk.sda = { disk.sda = {

View file

@ -1,5 +1,5 @@
_: {pkgs, ...}: { _: {pkgs, ...}: {
nixpkgs.allowedUnfree = ["hplip"]; local.allowedUnfree = ["hplip"];
environment.systemPackages = [ environment.systemPackages = [
pkgs.gimp pkgs.gimp
(pkgs.xsane.override {gimpSupport = true;}) (pkgs.xsane.override {gimpSupport = true;})

View file

@ -44,7 +44,12 @@
logo = "${self.packages.${pkgs.system}.images}/logo.png"; logo = "${self.packages.${pkgs.system}.images}/logo.png";
}; };
loader = { loader = {
grub.configurationLimit = 10; grub = {
configurationLimit = 10;
extraConfig = ''
GRUB_TIMEOUT_STYLE=hidden
'';
};
systemd-boot = { systemd-boot = {
configurationLimit = 10; configurationLimit = 10;
enable = lib.mkDefault true; enable = lib.mkDefault true;

View file

@ -1,146 +0,0 @@
_: {
lib,
config,
pkgs,
...
}: let
cfg = config.programs.direnv;
in {
options.programs.direnv = {
enable = lib.mkEnableOption (lib.mdDoc ''
direnv integration. Takes care of both installation and
setting up the sourcing of the shell. Additionally enables nix-direnv
integration. Note that you need to logout and login for this change to apply.
'');
package = lib.mkPackageOptionMD pkgs "direnv" {};
direnvrcExtra = lib.mkOption {
type = lib.types.lines;
default = "";
example = ''
export FOO="foo"
echo "loaded direnv!"
'';
description = lib.mdDoc ''
Extra lines to append to the sourced direnvrc
'';
};
silent = lib.mkEnableOption (lib.mdDoc ''
the hiding of direnv logging
'');
persistDerivations =
(lib.mkEnableOption (lib.mdDoc ''
setting keep-derivations and keep-outputs to true
to prevent shells from getting garbage collected
''))
// {
default = true;
};
loadInNixShell =
lib.mkEnableOption (lib.mdDoc ''
loading direnv only outside of `nix-shell` `nix shell` or `nix develop`
'')
// {
default = true;
};
nix-direnv = {
enable =
(lib.mkEnableOption (lib.mdDoc ''
a faster, persistent implementation of use_nix and use_flake, to replace the built-in one
''))
// {
default = true;
};
package = lib.mkPackageOptionMD pkgs "nix-direnv" {};
};
};
config = lib.mkIf cfg.enable {
programs = {
zsh.interactiveShellInit = ''
if ${lib.boolToString cfg.loadInNixShell} || printenv PATH | grep -vqc '/nix/store'; then
eval "$(${lib.getExe cfg.package} hook zsh)"
fi
'';
#$NIX_GCROOT for "nix develop" https://github.com/NixOS/nix/blob/6db66ebfc55769edd0c6bc70fcbd76246d4d26e0/src/nix/develop.cc#L530
#$IN_NIX_SHELL for "nix-shell"
bash.interactiveShellInit = ''
if ${lib.boolToString cfg.loadInNixShell} || [ -z "$IN_NIX_SHELL$NIX_GCROOT$(printenv PATH | grep '/nix/store')" ] ; then
eval "$(${lib.getExe cfg.package} hook bash)"
fi
'';
fish.interactiveShellInit = ''
if ${lib.boolToString cfg.loadInNixShell};
or printenv PATH | grep -vqc '/nix/store';
${lib.getExe cfg.package} hook fish | source
end
'';
};
nix.settings = lib.mkIf cfg.persistDerivations {
keep-outputs = true;
keep-derivations = true;
};
environment = {
systemPackages =
#direnv has a fish library which sources direnv for some reason
if cfg.loadInNixShell
then [cfg.package]
else [
(cfg.package.overrideAttrs (old: {
installPhase =
(old.installPhase or "")
+ ''
rm -rf $out/share/fish
'';
}))
];
variables = {
DIRENV_CONFIG = "/etc/direnv";
DIRENV_LOG_FORMAT = lib.mkIf cfg.silent "";
};
etc = {
"direnv/direnvrc".text = ''
${lib.optionalString cfg.nix-direnv.enable ''
#Load nix-direnv
source ${cfg.nix-direnv.package}/share/nix-direnv/direnvrc
''}
#Load direnvrcExtra
${cfg.direnvrcExtra}
#Load user-configuration if present (~/.direnvrc or ~/.config/direnv/direnvrc)
direnv_config_dir_home="''${DIRENV_CONFIG_HOME:-''${XDG_CONFIG_HOME:-$HOME/.config}/direnv}"
if [[ -f $direnv_config_dir_home/direnvrc ]]; then
source "$direnv_config_dir_home/direnvrc" >&2
elif [[ -f $HOME/.direnvrc ]]; then
source "$HOME/.direnvrc" >&2
fi
unset direnv_config_dir_home
'';
"direnv/lib/zz-user.sh".text = ''
direnv_config_dir_home="''${DIRENV_CONFIG_HOME:-''${XDG_CONFIG_HOME:-$HOME/.config}/direnv}"
for lib in "$direnv_config_dir_home/lib/"*.sh; do
source "$lib"
done
unset direnv_config_dir_home
'';
};
};
};
}

View file

@ -4,18 +4,13 @@ _: {
pkgs, pkgs,
... ...
}: { }: {
options = { options.local.allowedUnfree = lib.mkOption {
dummyvalue = lib.mkOption { type = lib.types.listOf lib.types.string;
default = {}; default = [];
};
nixpkgs.allowedUnfree = lib.mkOption {
type = lib.types.listOf lib.types.string;
default = [];
};
}; };
config = { config = {
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.nixpkgs.allowedUnfree; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.local.allowedUnfree;
environment.defaultPackages = lib.mkForce (builtins.attrValues { environment.defaultPackages = lib.mkForce (builtins.attrValues {
inherit inherit