This commit is contained in:
m3tam3re 2024-11-02 18:03:16 +01:00
parent d0b1d9b775
commit d22b436fb1
5 changed files with 159 additions and 1 deletions

33
flake.lock generated
View File

@ -172,6 +172,23 @@
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1730184279,
"narHash": "sha256-6OB+WWR6gnaWiqSS28aMJypKeK7Pjc2Wm6L0MtOrTuA=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "b379bd4d872d159e5189053ce9a4adf86d56db4b",
"type": "github"
},
"original": {
"id": "nix-darwin",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1703013332,
@ -221,6 +238,19 @@
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1729665710,
"narHash": "sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4=",
"path": "/nix/store/lsy6c2f9alj2gkjj36h754kk63x6701l-source",
"rev": "2768c7d042a37de65bb1b5b3268fc987e534c49d",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1726463316,
"narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=",
@ -243,7 +273,8 @@
"disko": "disko",
"dotfiles": "dotfiles",
"home-manager": "home-manager_2",
"nixpkgs": "nixpkgs_3",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs_4",
"nixpkgs-stable": "nixpkgs-stable"
}
},

View File

@ -37,6 +37,7 @@
self,
agenix,
home-manager,
nix-darwin,
nixpkgs,
nixpkgs-stable,
...

View File

@ -38,6 +38,7 @@
./configuration.nix
./secrets.nix
./services
./specialisations.nix
];
extraServices.podman.enable = true;
}

View File

@ -0,0 +1,83 @@
{
config,
lib,
pkgs,
...
}: {
specialisation = {
"HTTPD".configuration = {
system.nixos.tags = ["HTTPD"];
services.httpd.enable = true;
services.httpd.virtualHosts."foo.example.com" = {
documentRoot = "/var/www/foo";
extraConfig = ''
<Directory /var/www/foo>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
'';
};
};
"NGINX".configuration = {
system.nixos.tags = ["NGINX"];
services.httpd.enable = false;
services.nginx.enable = true;
services.nginx.config = ''
http {
server {
listen 80;
server_name bar.example.com;
root /var/www/bar;
location / {
index index.html;
}
}
}
'';
};
"NVIDIA".configuration = {
boot.kernelParams = [
"nvidia.NVreg_PreserveVideoMemoryAllocations=1"
"nvidia-drm.modeset=1"
];
system.nixos.tags = ["NVIDIA"];
services.xserver.videoDrivers = ["nvidia"];
hardware = {
nvidia = {
open = false;
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
powerManagement.enable = true;
};
graphics = {
enable = true;
enable32Bit = true;
};
};
environment.sessionVariables = {
GBM_BACKEND = "nvidia-drm";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
LIBVA_DRIVER_NAME = "nvidia";
QT_QPA_PLATFORM = "wayland";
WLR_NO_HARDWARE_CURSORS = "1";
XDG_SESSION_TYPE = "wayland";
};
};
};
environment.systemPackages = [
(pkgs.writeShellScriptBin "switch-spec" ''
if [ $# -ne 1 ]; then
echo "Usage: switch-spec <specialisation>"
exit 1
fi
sudo /nix/var/nix/profiles/system/specialisation/$1/bin/switch-to-configuration switch
'')
];
environment.sessionVariables = lib.mkIf (config.specialisation != {}) {
SPECIALISATION = "NONE";
};
}

42
justfile Normal file
View File

@ -0,0 +1,42 @@
# List available commands
default:
@just --list
# Deploy system configuration
deploy SYSTEM:
nixos-rebuild switch --flake .#{{SYSTEM}} --target-host {{SYSTEM}} --use-remote-sudo
# Update flake
update:
nix flake update
# Commit and push changes
commit MESSAGE:
git add .
git commit -m "{{MESSAGE}}"
git push
# Update, commit, and push changes
update-and-commit MESSAGE: update
@just commit "{{MESSAGE}}"
# Deploy, update, commit, and push changes
deploy-update-commit SYSTEM MESSAGE: (deploy SYSTEM) update
@just commit "{{MESSAGE}}"
# Check flake
check:
nix flake check
# Show flake info
show:
nix flake show
# Build system configuration
build SYSTEM:
nixos-rebuild build --flake .#{{SYSTEM}}
# Enter a development shell
dev-shell:
nix develop