This commit is contained in:
Lukas Wurzinger 2024-07-02 00:06:05 +02:00
parent d23c039131
commit f59e1af4bd
20 changed files with 62 additions and 157 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.direnv/

View file

@ -14,6 +14,7 @@
./plasma.nix ./plasma.nix
./printing.nix ./printing.nix
./syncthing.nix ./syncthing.nix
./users.nix
./vm.nix ./vm.nix
./wine.nix ./wine.nix
]; ];

View file

@ -1,14 +1,5 @@
{ {
boot.initrd.luks.devices.main.device = "/dev/disk/by-label/cryptmain"; boot.initrd.luks.devices.main.device = "/dev/disk/by-label/cryptmain";
fileSystems = { fileSystems."/".device = "/dev/mapper/main";
"/home" = {
device = "/dev/mapper/main";
fsType = "btrfs";
options = ["subvol=home" "compress=zstd" "noatime"];
};
"/nix".device = "/dev/mapper/main";
"/persist".device = "/dev/mapper/main";
"/var/log".device = "/dev/mapper/main";
};
} }

View file

@ -1,6 +1,4 @@
{pkgs, ...}: { {pkgs, ...}: {
environment.persistence."/persist".directories = ["/etc/mullvad-vpn"];
services.mullvad-vpn = { services.mullvad-vpn = {
enable = true; enable = true;
package = pkgs.mullvad-vpn; package = pkgs.mullvad-vpn;

View file

@ -1,6 +1,4 @@
{ {
environment.persistence."/persist".directories = ["/etc/NetworkManager"];
services.resolved.enable = true; services.resolved.enable = true;
networking = { networking = {

View file

@ -11,25 +11,15 @@
}; };
}; };
environment = { environment.systemPackages = with pkgs.kdePackages; [sddm-kcm discover kate];
systemPackages = with pkgs.kdePackages; [discover kate];
sessionVariables = { programs = {
SUDO_ASKPASS = pkgs.writeShellScript "kdialogaskpass" '' kdeconnect.enable = true;
exec ${lib.getExe' pkgs.kdialog "kdialog"} --password Askpass partition-manager.enable = true;
'';
MOZ_USE_XINPUT2 = "1";
GDK_SCALE = "1";
};
}; };
xdg.portal = { xdg.portal = {
xdgOpenUsePortal = true; xdgOpenUsePortal = true;
extraPortals = [pkgs.xdg-desktop-portal-gtk]; extraPortals = [pkgs.xdg-desktop-portal-gtk];
}; };
programs = {
kdeconnect.enable = true;
partition-manager.enable = true;
dconf.enable = true;
};
} }

3
class/desktop/users.nix Normal file
View file

@ -0,0 +1,3 @@
{
users.mutableUsers = true;
}

View file

@ -1,12 +1,3 @@
{ {
fileSystems = { fileSystems."/".device = "/dev/disk/by-label/main";
"/home" = {
device = "tmpfs";
fsType = "tmpfs";
options = ["size=4G" "mode=751"];
};
"/nix".device = "/dev/disk/by-label/main";
"/persist".device = "/dev/disk/by-label/main";
"/var/log".device = "/dev/disk/by-label/main";
};
} }

3
class/server/users.nix Normal file
View file

@ -0,0 +1,3 @@
{
users.mutableUsers = false;
}

View file

@ -2,4 +2,14 @@
programs.fish.enable = true; programs.fish.enable = true;
users.defaultUserShell = pkgs.fish; users.defaultUserShell = pkgs.fish;
nixpkgs.overlays = [
(final: prev: {
fish = prev.fish.overrideAttrs (oldAttrs: {
postInstall = ''
rm $out/share/applications/fish.desktop
'';
});
})
];
} }

View file

@ -1,38 +1,14 @@
{ {
boot.tmp.cleanOnBoot = true;
fileSystems = { fileSystems = {
"/" = { "/" = {
device = "tmpfs"; fsType = "ext4";
fsType = "tmpfs"; options = ["noatime"];
options = ["size=4G" "mode=755"];
}; };
"/boot" = { "/boot" = {
device = "/dev/disk/by-label/BOOT"; device = "/dev/disk/by-label/BOOT";
fsType = "vfat"; fsType = "vfat";
}; };
"/home".neededForBoot = true;
"/nix" = {
fsType = "btrfs";
options = ["subvol=nix" "compress=zstd" "noatime"];
};
"/persist" = {
fsType = "btrfs";
options = ["subvol=persist" "compress=zstd" "noatime"];
neededForBoot = true;
};
"/tmp" = {
device = "tmpfs";
fsType = "tmpfs";
options = ["size=8G" "mode=777"];
};
"/var/log" = {
fsType = "btrfs";
options = ["subvol=log" "compress=zstd" "noatime"];
neededForBoot = true;
};
};
environment.persistence."/persist" = {
directories = ["/var/lib" "/var/cache"];
files = ["/etc/machine-id"];
}; };
} }

View file

@ -5,7 +5,11 @@
... ...
}: { }: {
environment = let environment = let
package = inputs.myvim.packages.${pkgs.system}.default; package = inputs.myvim.packages.${pkgs.system}.default.overrideAttrs (oldAttrs: {
postInstall = ''
rm $out/share/applications/nvim.desktop
'';
});
in { in {
systemPackages = [package]; systemPackages = [package];
variables = lib.genAttrs ["EDITOR" "VISUAL"] (_: lib.getExe package); variables = lib.genAttrs ["EDITOR" "VISUAL"] (_: lib.getExe package);

View file

@ -3,12 +3,7 @@
pkgs, pkgs,
... ...
}: { }: {
environment.persistence."/persist".files = [ age.identityPaths = ["/etc/ssh/ssh_host_ed25519_key"];
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub"
];
age.identityPaths = ["/persist/etc/ssh/ssh_host_ed25519_key"];
services.openssh = { services.openssh = {
enable = true; enable = true;
@ -27,6 +22,7 @@
programs.ssh = { programs.ssh = {
startAgent = true; startAgent = true;
enableAskPassword = true;
askPassword = lib.getExe' pkgs.ksshaskpass "ksshaskpass"; askPassword = lib.getExe' pkgs.ksshaskpass "ksshaskpass";
}; };

View file

@ -2,13 +2,12 @@
age.secrets.user-lukas.file = ../secrets/user-lukas.age; age.secrets.user-lukas.file = ../secrets/user-lukas.age;
users = { users = {
mutableUsers = false; groups.lukas.gid = 1000;
groups.lukas = {};
users = { users = {
root.hashedPassword = "!"; root.hashedPassword = "!";
lukas = { lukas = {
uid = 1000;
isNormalUser = true; isNormalUser = true;
hashedPasswordFile = config.age.secrets.user-lukas.path; hashedPasswordFile = config.age.secrets.user-lukas.path;
openssh.authorizedKeys.keys = builtins.attrValues (import ../pubkeys.nix).users; openssh.authorizedKeys.keys = builtins.attrValues (import ../pubkeys.nix).users;
@ -17,6 +16,4 @@
}; };
}; };
}; };
services.displayManager.sddm.settings.Autologin.User = "lukas";
} }

32
disk.sh
View file

@ -91,37 +91,9 @@ while true; do
esac esac
done done
mkfs.btrfs --force --quiet --label "$mainlbl" -- "$mainfs" mkfs.ext4 -q -F -L "$mainlbl" -- "$mainfs"
mkdir --parents -- "$root" mkdir --parents -- "$root"
mount -- "$mainfs" "$root" mount --options noatime -- "$mainfs" "$root"
declare -A vols
while true; do
read -r -p 'Add a subvolume: ' vol
if [[ "$vol" == '' ]]; then
break
fi
read -r -p 'Add a subvolume path: ' path
if [[ "$path" == '' ]]; then
path="$vol"
fi
vols["$vol"]="$path"
done
for vol in "${!vols[@]}"; do
btrfs --quiet subvolume create -- "$root/$vol"
done
umount -- "$root"
mount -t tmpfs -o size=2G,mode=755 tmpfs -- "$root"
for vol in "${!vols[@]}"; do
mkdir --parents -- "$root/${vols["$vol"]}"
mount --options "subvol=$vol,compress=zstd,noatime" -- "$mainfs" "$root/${vols["$vol"]}"
done
mkdir -- "$root/boot" mkdir -- "$root/boot"
mount -- "$bootfs" "$root/boot" mount -- "$bootfs" "$root/boot"

View file

@ -8,11 +8,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1712079060, "lastModified": 1718371084,
"narHash": "sha256-/JdiT9t+zzjChc5qQiF+jhrVhRt8figYH29rZO7pFe4=", "narHash": "sha256-abpBi61mg0g+lFFU0zY4C6oP6fBwPzbHPKBGw676xsA=",
"owner": "ryantm", "owner": "ryantm",
"repo": "agenix", "repo": "agenix",
"rev": "1381a759b205dff7a6818733118d02253340fd5e", "rev": "3a56735779db467538fb2e577eda28a9daacaca6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -101,11 +101,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1712014858, "lastModified": 1719745305,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", "narHash": "sha256-xwgjVUpqSviudEkpQnioeez1Uo2wzrsMaJKJClh+Bls=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", "rev": "c3c5ecc05edc7dafba779c6c1a61cd08ac6583e9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -215,11 +215,11 @@
}, },
"hardware": { "hardware": {
"locked": { "locked": {
"lastModified": 1713521961, "lastModified": 1719681865,
"narHash": "sha256-EwR8wW9AqJhSIY+0oxWRybUZ32BVKuZ9bjlRh8SJvQ8=", "narHash": "sha256-Lp+l1IsREVbz8WM35OJYZz8sAH0XOjrZWUXVB5bJ2qg=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "5d48925b815fd202781bfae8fb6f45c07112fdb2", "rev": "a59f00f5ac65b19382617ba00f360f8bc07ed3ac",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -271,21 +271,6 @@
"type": "github" "type": "github"
} }
}, },
"impermanence": {
"locked": {
"lastModified": 1708968331,
"narHash": "sha256-VUXLaPusCBvwM3zhGbRIJVeYluh2uWuqtj4WirQ1L9Y=",
"owner": "nix-community",
"repo": "impermanence",
"rev": "a33ef102a02ce77d3e39c25197664b7a636f9c30",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "impermanence",
"type": "github"
}
},
"myvim": { "myvim": {
"inputs": { "inputs": {
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_2",
@ -346,20 +331,14 @@
}, },
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"dir": "lib", "lastModified": 1717284937,
"lastModified": 1711703276, "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=",
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", "type": "tarball",
"owner": "NixOS", "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
"repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github"
}, },
"original": { "original": {
"dir": "lib", "type": "tarball",
"owner": "NixOS", "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
} }
}, },
"nixpkgs-lib_2": { "nixpkgs-lib_2": {
@ -414,11 +393,11 @@
}, },
"nixpkgs_4": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1713537308, "lastModified": 1719690277,
"narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", "rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -487,7 +466,6 @@
"agenix": "agenix", "agenix": "agenix",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"hardware": "hardware", "hardware": "hardware",
"impermanence": "impermanence",
"myvim": "myvim", "myvim": "myvim",
"nixpkgs": "nixpkgs_4" "nixpkgs": "nixpkgs_4"
} }

View file

@ -5,7 +5,6 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
hardware.url = "github:NixOS/nixos-hardware"; hardware.url = "github:NixOS/nixos-hardware";
impermanence.url = "github:nix-community/impermanence";
agenix.url = "github:ryantm/agenix"; agenix.url = "github:ryantm/agenix";
myvim.url = "github:lukaswrz/myvim"; myvim.url = "github:lukaswrz/myvim";
}; };
@ -26,7 +25,6 @@
attrName = name; attrName = name;
}; };
modules = [ modules = [
inputs.impermanence.nixosModules.impermanence
inputs.agenix.nixosModules.default inputs.agenix.nixosModules.default
./common ./common
@ -62,7 +60,7 @@
runtimeInputs = with pkgs; [ runtimeInputs = with pkgs; [
util-linux util-linux
jq jq
btrfs-progs e2fsprogs
dosfstools dosfstools
]; ];

View file

@ -3,8 +3,6 @@
pkgs, pkgs,
... ...
}: { }: {
environment.persistence."/persist".directories = ["/var/www"];
services.nginx = { services.nginx = {
enable = true; enable = true;
package = pkgs.nginxQuic; package = pkgs.nginxQuic;

View file

@ -24,7 +24,9 @@
binfmt.emulatedSystems = ["aarch64-linux"]; binfmt.emulatedSystems = ["aarch64-linux"];
}; };
system.stateVersion = "24.05"; system.stateVersion = "24.11";
powerManagement.cpuFreqGovernor = "performance"; powerManagement.cpuFreqGovernor = "performance";
networking.firewall.enable = false;
} }

View file

@ -24,6 +24,4 @@
system.stateVersion = "24.05"; system.stateVersion = "24.05";
powerManagement.cpuFreqGovernor = "powersave"; powerManagement.cpuFreqGovernor = "powersave";
environment.persistence."/persist".directories = ["/srv/storage"];
} }