-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: consolidate NixOS hosts into shared builder #1473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
61e5111
8324b85
233f4c7
db805ca
f2950b3
95d81f3
4895dd0
271fb94
6915b54
b8e186d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +0,0 @@ | ||
| function _pixelh_function --description "Run Pi headlessly with the local Qwen model" | ||
| # Prompt for input and run Pi in print mode with the local Qwen model | ||
| # Usage: pixelh | ||
|
|
||
| set -l prompt | ||
| if test (count $argv) -gt 0 | ||
| set prompt (string join " " $argv) | ||
| else | ||
| read -P "Prompt: " prompt | ||
| end | ||
|
|
||
| if test -z "$prompt" | ||
| echo "No prompt provided, aborting." >&2 | ||
| return 1 | ||
| end | ||
|
|
||
| pi --model 'lmstudio/qwen3.5-0.8b-optiq' -p "$prompt" | ||
| end | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,134 +1,158 @@ | ||||||||||||||||
| # Shared NixOS system builder. | ||||||||||||||||
| # All NixOS hosts call this with their specific modules. | ||||||||||||||||
| # When no modules are passed, includes generic config (x86_64-linux/runner). | ||||||||||||||||
| { | ||||||||||||||||
| inputs, | ||||||||||||||||
| username, | ||||||||||||||||
| hostname ? "x86_64-linux", | ||||||||||||||||
| isRunner ? false, | ||||||||||||||||
| system ? "x86_64-linux", | ||||||||||||||||
| stateVersion ? "24.11", | ||||||||||||||||
| userExtraGroups ? [ ], | ||||||||||||||||
| userInitialPassword ? null, | ||||||||||||||||
| modules ? null, | ||||||||||||||||
| specialArgs ? { }, | ||||||||||||||||
| }: | ||||||||||||||||
| let | ||||||||||||||||
| inherit (inputs) nixpkgs home-manager; | ||||||||||||||||
| system = "x86_64-linux"; | ||||||||||||||||
| nixpkgsConfig = import ../../lib/nixpkgs-config.nix { | ||||||||||||||||
| nixpkgsLib = nixpkgs.lib; | ||||||||||||||||
| nixpkgsLib = inputs.nixpkgs.lib; | ||||||||||||||||
| }; | ||||||||||||||||
| overlays = import ../../overlays { inherit inputs; }; | ||||||||||||||||
| pkgs = import nixpkgs { | ||||||||||||||||
| pkgs = import inputs.nixpkgs { | ||||||||||||||||
| inherit system overlays; | ||||||||||||||||
| config = nixpkgsConfig; | ||||||||||||||||
| }; | ||||||||||||||||
| configuration = | ||||||||||||||||
|
|
||||||||||||||||
| # Shared base: every NixOS host gets this | ||||||||||||||||
| baseModule = | ||||||||||||||||
| { lib, ... }: | ||||||||||||||||
| { | ||||||||||||||||
| boot.loader.grub.enable = true; | ||||||||||||||||
| boot.loader.grub.device = "/dev/sda"; | ||||||||||||||||
| boot.loader.grub.useOSProber = true; | ||||||||||||||||
| boot.loader.systemd-boot.configurationLimit = 10; | ||||||||||||||||
|
|
||||||||||||||||
| networking.hostName = hostname; | ||||||||||||||||
| networking.networkmanager.enable = true; | ||||||||||||||||
|
|
||||||||||||||||
| programs.fish.enable = true; | ||||||||||||||||
|
|
||||||||||||||||
| users.users.${username} = { | ||||||||||||||||
| isNormalUser = true; | ||||||||||||||||
| extraGroups = [ | ||||||||||||||||
| "wheel" | ||||||||||||||||
| "networkmanager" | ||||||||||||||||
| ]; | ||||||||||||||||
| ] | ||||||||||||||||
| ++ userExtraGroups; | ||||||||||||||||
| home = "/home/${username}"; | ||||||||||||||||
| hashedPassword = if isRunner then "" else null; | ||||||||||||||||
| openssh.authorizedKeys.keys = [ ]; | ||||||||||||||||
| shell = pkgs.fish; | ||||||||||||||||
| } | ||||||||||||||||
| // lib.optionalAttrs (userInitialPassword != null) { | ||||||||||||||||
| initialPassword = userInitialPassword; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| users.users.root.hashedPassword = if isRunner then "" else null; | ||||||||||||||||
|
|
||||||||||||||||
| security.sudo.wheelNeedsPassword = false; | ||||||||||||||||
|
|
||||||||||||||||
| virtualisation = lib.mkIf isRunner { | ||||||||||||||||
| vmware.guest.enable = true; | ||||||||||||||||
|
|
||||||||||||||||
| libvirtd.enable = true; | ||||||||||||||||
|
|
||||||||||||||||
| virtualbox.guest.enable = false; | ||||||||||||||||
|
|
||||||||||||||||
| vmVariant = { | ||||||||||||||||
| virtualisation = { | ||||||||||||||||
| memorySize = 4096; | ||||||||||||||||
| cores = 2; | ||||||||||||||||
| }; | ||||||||||||||||
| virtualisation.graphics = false; | ||||||||||||||||
| virtualisation.sharedDirectories = { | ||||||||||||||||
| shared = { | ||||||||||||||||
| source = "$PWD"; | ||||||||||||||||
| target = "/mnt/shared"; | ||||||||||||||||
| }; | ||||||||||||||||
| }; | ||||||||||||||||
| }; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| environment.systemPackages = with pkgs; [ | ||||||||||||||||
| curl | ||||||||||||||||
| git | ||||||||||||||||
| home-manager | ||||||||||||||||
| vim | ||||||||||||||||
| wget | ||||||||||||||||
| zellij | ||||||||||||||||
| ]; | ||||||||||||||||
|
|
||||||||||||||||
| services.getty.autologinUser = lib.mkIf isRunner "root"; | ||||||||||||||||
|
|
||||||||||||||||
| boot.loader.timeout = lib.mkIf isRunner 0; | ||||||||||||||||
|
|
||||||||||||||||
| nix = { | ||||||||||||||||
| channel.enable = false; | ||||||||||||||||
| settings = { | ||||||||||||||||
| experimental-features = [ | ||||||||||||||||
| "nix-command" | ||||||||||||||||
| "flakes" | ||||||||||||||||
| ]; | ||||||||||||||||
| nix-path = lib.mkForce "nixpkgs=/etc/nix/inputs/nixpkgs"; | ||||||||||||||||
| substituters = [ | ||||||||||||||||
| "https://cache.nixos.org" | ||||||||||||||||
| ]; | ||||||||||||||||
| trusted-users = [ | ||||||||||||||||
| "root" | ||||||||||||||||
| username | ||||||||||||||||
| "@wheel" | ||||||||||||||||
| ]; | ||||||||||||||||
| }; | ||||||||||||||||
| package = pkgs.nixVersions.stable; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| boot.consoleLogLevel = 7; | ||||||||||||||||
| services.journald.extraConfig = "Storage=volatile"; | ||||||||||||||||
| environment.etc."nix/inputs/nixpkgs".source = "${inputs.nixpkgs}"; | ||||||||||||||||
|
|
||||||||||||||||
| system.stateVersion = "24.05"; | ||||||||||||||||
| system.stateVersion = stateVersion; | ||||||||||||||||
| }; | ||||||||||||||||
| in | ||||||||||||||||
| nixpkgs.lib.nixosSystem { | ||||||||||||||||
| inherit system; | ||||||||||||||||
| inherit (nixpkgs) lib; | ||||||||||||||||
| specialArgs = { | ||||||||||||||||
| inherit username isRunner; | ||||||||||||||||
| }; | ||||||||||||||||
| modules = [ | ||||||||||||||||
| configuration | ||||||||||||||||
| { | ||||||||||||||||
| fileSystems."/" = { | ||||||||||||||||
| device = "/dev/sda1"; | ||||||||||||||||
| fsType = "ext4"; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| nixpkgs.pkgs = pkgs; | ||||||||||||||||
| # Generic config for x86_64-linux/runner (used when modules == null) | ||||||||||||||||
| genericModules = [ | ||||||||||||||||
| ( | ||||||||||||||||
| { lib, ... }: | ||||||||||||||||
| { | ||||||||||||||||
| boot.loader.grub.enable = true; | ||||||||||||||||
| boot.loader.grub.device = "/dev/sda"; | ||||||||||||||||
| boot.loader.grub.useOSProber = true; | ||||||||||||||||
| boot.loader.systemd-boot.configurationLimit = 10; | ||||||||||||||||
|
Comment on lines
+81
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conflicting boot loader configuration.
Either remove line 86 since it's ineffective with GRUB, or clarify the intent if this is meant as a fallback configuration. Proposed fix boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/sda";
boot.loader.grub.useOSProber = true;
- boot.loader.systemd-boot.configurationLimit = 10;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| fonts.packages = with pkgs; [ | ||||||||||||||||
| nerd-fonts.jetbrains-mono | ||||||||||||||||
| ]; | ||||||||||||||||
| } | ||||||||||||||||
| home-manager.nixosModules.home-manager | ||||||||||||||||
| users.users.${username} = { | ||||||||||||||||
| hashedPassword = if isRunner then "" else null; | ||||||||||||||||
| openssh.authorizedKeys.keys = [ ]; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| users.users.root.hashedPassword = if isRunner then "" else null; | ||||||||||||||||
|
|
||||||||||||||||
| virtualisation = lib.mkIf isRunner { | ||||||||||||||||
| vmware.guest.enable = true; | ||||||||||||||||
| libvirtd.enable = true; | ||||||||||||||||
| virtualbox.guest.enable = false; | ||||||||||||||||
| vmVariant = { | ||||||||||||||||
| virtualisation = { | ||||||||||||||||
| memorySize = 4096; | ||||||||||||||||
| cores = 2; | ||||||||||||||||
| }; | ||||||||||||||||
| virtualisation.graphics = false; | ||||||||||||||||
| virtualisation.sharedDirectories = { | ||||||||||||||||
| shared = { | ||||||||||||||||
| source = "$PWD"; | ||||||||||||||||
| target = "/mnt/shared"; | ||||||||||||||||
| }; | ||||||||||||||||
| }; | ||||||||||||||||
| }; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| services.getty.autologinUser = lib.mkIf isRunner "root"; | ||||||||||||||||
| boot.loader.timeout = lib.mkIf isRunner 0; | ||||||||||||||||
|
|
||||||||||||||||
| boot.consoleLogLevel = 7; | ||||||||||||||||
| services.journald.extraConfig = "Storage=volatile"; | ||||||||||||||||
|
|
||||||||||||||||
| fileSystems."/" = { | ||||||||||||||||
| device = "/dev/sda1"; | ||||||||||||||||
| fsType = "ext4"; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| fonts.packages = with pkgs; [ | ||||||||||||||||
| nerd-fonts.jetbrains-mono | ||||||||||||||||
| ]; | ||||||||||||||||
| } | ||||||||||||||||
| ) | ||||||||||||||||
| inputs.home-manager.nixosModules.home-manager | ||||||||||||||||
| { | ||||||||||||||||
| home-manager.backupFileExtension = "hm-backup"; | ||||||||||||||||
| home-manager.extraSpecialArgs = { inherit inputs; }; | ||||||||||||||||
| home-manager.useGlobalPkgs = true; | ||||||||||||||||
| home-manager.useUserPackages = true; | ||||||||||||||||
| home-manager.users."${username}" = import ../../home-manager { | ||||||||||||||||
| inherit inputs username; | ||||||||||||||||
| inherit (nixpkgs) lib; | ||||||||||||||||
| inherit (inputs.nixpkgs) lib; | ||||||||||||||||
| inherit pkgs; | ||||||||||||||||
| config = { }; | ||||||||||||||||
| }; | ||||||||||||||||
| } | ||||||||||||||||
| ]; | ||||||||||||||||
| in | ||||||||||||||||
| inputs.nixpkgs.lib.nixosSystem { | ||||||||||||||||
| inherit system; | ||||||||||||||||
| specialArgs = { | ||||||||||||||||
| inherit | ||||||||||||||||
| inputs | ||||||||||||||||
| username | ||||||||||||||||
| isRunner | ||||||||||||||||
| ; | ||||||||||||||||
| } | ||||||||||||||||
| // specialArgs; | ||||||||||||||||
| modules = [ | ||||||||||||||||
| { nixpkgs.pkgs = pkgs; } | ||||||||||||||||
| baseModule | ||||||||||||||||
| ] | ||||||||||||||||
| ++ (if modules == null then genericModules else modules); | ||||||||||||||||
| } | ||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Default
stateVersionchanged from"24.05"to"24.11". NixOSstateVersiongates backward-compatibility migrations and should not change after initial installation. Thetests/eval.nixevaluations foreval-nixos-defaultandeval-nixos-runnerdon't passstateVersion, so they now evaluate"24.11"while production uses"24.05"— meaning tests no longer match deployed config. Consider keeping the default as"24.05"to match the existing hosts.Prompt for AI agents