From 744cb9eb0db6d7ee8641cd55edcbfca40d3234ab Mon Sep 17 00:00:00 2001 From: Martin Pander Date: Fri, 6 Feb 2026 21:41:49 +0100 Subject: [PATCH] Refactor nix config --- newnix/flake.lock | 21 +++++ newnix/flake.nix | 68 +++++++++++--- newnix/hosts/home/darwin/configuration.nix | 19 ++++ newnix/hosts/home/nix/home.nix | 17 +++- newnix/hosts/home/nixos/configuration.nix | 70 ++++---------- newnix/hosts/home/nixos/flake.nix | 48 ---------- newnix/hosts/home/nixos/home.nix | 13 +++ newnix/hosts/work/nix/home.nix | 16 ++-- newnix/hosts/work/nixos/configuration.nix | 52 +---------- newnix/hosts/work/nixos/flake.nix | 48 ---------- newnix/hosts/work/nixos/home.nix | 18 +--- .../modules/home/{default.nix => common.nix} | 0 newnix/modules/home/dev.nix | 1 - newnix/modules/home/llm.nix | 1 + .../nixos/common.nix} | 7 +- newnix/nix/flake.nix | 91 ------------------- newnix/nix/martin.nix | 13 --- 17 files changed, 156 insertions(+), 347 deletions(-) create mode 100644 newnix/hosts/home/darwin/configuration.nix delete mode 100644 newnix/hosts/home/nixos/flake.nix create mode 100644 newnix/hosts/home/nixos/home.nix delete mode 100644 newnix/hosts/work/nixos/flake.nix rename newnix/modules/home/{default.nix => common.nix} (100%) rename newnix/{nixos/configuration.nix => modules/nixos/common.nix} (84%) delete mode 100644 newnix/nix/flake.nix delete mode 100644 newnix/nix/martin.nix diff --git a/newnix/flake.lock b/newnix/flake.lock index f0f3c02..9d1fa68 100644 --- a/newnix/flake.lock +++ b/newnix/flake.lock @@ -36,6 +36,26 @@ "type": "github" } }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1770184146, + "narHash": "sha256-DsqnN6LvXmohTRaal7tVZO/AKBuZ02kPBiZKSU4qa/k=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "0d7874ef7e3ba02d58bebb871e6e29da36fa1b37", + "type": "github" + }, + "original": { + "owner": "LnL7", + "repo": "nix-darwin", + "type": "github" + } + }, "nixos-wsl": { "inputs": { "flake-compat": "flake-compat", @@ -76,6 +96,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "nix-darwin": "nix-darwin", "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs" } diff --git a/newnix/flake.nix b/newnix/flake.nix index 2c2e3f5..096886d 100644 --- a/newnix/flake.nix +++ b/newnix/flake.nix @@ -1,44 +1,88 @@ { - description = "NixOS Shared Configuration"; + description = "Unified Nix Configuration"; inputs = { - # Use nixos-unstable for latest packages nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - # NixOS-WSL for WSL-specific functionality nixos-wsl = { url = "github:nix-community/NixOS-WSL"; inputs.nixpkgs.follows = "nixpkgs"; }; - # Home Manager for user configuration home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + + nix-darwin = { + url = "github:LnL7/nix-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, nixos-wsl, home-manager, ... }: + outputs = { self, nixpkgs, nixos-wsl, home-manager, nix-darwin, ... }@inputs: let - system = "x86_64-linux"; + linuxSystem = "x86_64-linux"; + darwinSystem = "aarch64-darwin"; + + pkgsLinux = nixpkgs.legacyPackages.${linuxSystem}; + pkgsDarwin = nixpkgs.legacyPackages.${darwinSystem}; in { + + # --- NixOS Systems --- nixosConfigurations = { - nix = nixpkgs.lib.nixosSystem { - inherit system; + + # Work WSL + work = nixpkgs.lib.nixosSystem { + system = linuxSystem; + specialArgs = { inherit self; }; modules = [ nixos-wsl.nixosModules.wsl - - ./hosts/work/configuration.nix - + ./hosts/work/nixos/configuration.nix home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.users.pan = import ./hosts/work/home.nix; + home-manager.users.pan = import ./hosts/work/nixos/home.nix; + } + ]; + }; + + # Home + home = nixpkgs.lib.nixosSystem { + system = linuxSystem; + specialArgs = { inherit self; }; + modules = [ + ./hosts/home/nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.martin = import ./hosts/home/nixos/home.nix; } ]; }; }; + + # --- Darwin Systems (Mac) --- + darwinConfigurations."Martins-MacBook-Pro" = nix-darwin.lib.darwinSystem { + system = darwinSystem; + specialArgs = { inherit self; }; + modules = [ ./hosts/home/darwin/configuration.nix ]; + }; + + # --- Standalone Home Manager --- + homeConfigurations = { + "pan@work" = home-manager.lib.homeManagerConfiguration { + pkgs = pkgsLinux; + modules = [ ./hosts/work/nix/home.nix ]; + }; + + "martin@mac" = home-manager.lib.homeManagerConfiguration { + pkgs = pkgsDarwin; + modules = [ ./hosts/home/nix/home.nix ]; + }; + }; }; } diff --git a/newnix/hosts/home/darwin/configuration.nix b/newnix/hosts/home/darwin/configuration.nix new file mode 100644 index 0000000..f10a7ff --- /dev/null +++ b/newnix/hosts/home/darwin/configuration.nix @@ -0,0 +1,19 @@ +{ config, pkgs, self, ... }: + +{ + # Minimal system configuration + environment.systemPackages = [ pkgs.vim ]; + + services.nix-daemon.enable = true; + + nix.settings.experimental-features = "nix-command flakes"; + + programs.zsh.enable = true; + + # Set Git commit hash for darwin-version. + system.configurationRevision = self.rev or self.dirtyRev or null; + + system.stateVersion = 4; + + nixpkgs.hostPlatform = "aarch64-darwin"; +} diff --git a/newnix/hosts/home/nix/home.nix b/newnix/hosts/home/nix/home.nix index 4f9fc00..b3370ff 100644 --- a/newnix/hosts/home/nix/home.nix +++ b/newnix/hosts/home/nix/home.nix @@ -1,13 +1,22 @@ { config, pkgs, ... }: { + imports = [ + ../../../modules/home/common.nix + ]; + home.username = "martin"; home.homeDirectory = "/Users/martin"; - home.stateVersion = "24.05"; # Please read the comment before changing. + home.stateVersion = "24.05"; - programs.git = { - userName = "Martin"; - userEmail = "git@pander-on.de"; + programs.git.settings.user = { + name = "Martin Pander"; + email = "git@pander-on.de"; + }; + + programs.jujutsu.settings.user = { + name = "Martin Pander"; + email = "git@pander-on.de"; }; } diff --git a/newnix/hosts/home/nixos/configuration.nix b/newnix/hosts/home/nixos/configuration.nix index a84c00f..c9ad09c 100644 --- a/newnix/hosts/home/nixos/configuration.nix +++ b/newnix/hosts/home/nixos/configuration.nix @@ -1,71 +1,33 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page, on -# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). - -# NixOS-WSL specific options are documented on the NixOS-WSL repository: -# https://github.com/nix-community/NixOS-WSL - { config, lib, pkgs, ... }: { - wsl.enable = true; - wsl.defaultUser = "pan"; - wsl.interop.register = true; + imports = [ + ../../../modules/nixos/common.nix + ]; - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It's perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "25.05"; # Did you read the comment? + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "nix"; - #networking.networkmanager.enable = true; - - time.timeZone = "Europe/Berlin"; # Adjust to your timezone - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "de_DE.UTF-8"; - LC_IDENTIFICATION = "de_DE.UTF-8"; - LC_MEASUREMENT = "de_DE.UTF-8"; - LC_MONETARY = "de_DE.UTF-8"; - LC_NAME = "de_DE.UTF-8"; - LC_NUMERIC = "de_DE.UTF-8"; - LC_PAPER = "de_DE.UTF-8"; - LC_TELEPHONE = "de_DE.UTF-8"; - LC_TIME = "de_DE.UTF-8"; + fileSystems."/" = { + device = "/dev/disk/by-label/nixos"; + fsType = "ext4"; }; - users.users.pan = { + networking.hostName = "macnix"; + + users.users.martin = { isNormalUser = true; extraGroups = [ "networkmanager" "wheel" ]; uid = 1000; shell = pkgs.zsh; }; - programs.zsh.enable = true; + services.spice-vdagentd.enable = true; + services.qemuGuest.enable = true; - nix.settings = { - experimental-features = [ "nix-command" "flakes" ]; - }; + services.xserver.videoDrivers = [ "virtio" ]; - nixpkgs.config.allowUnfree = true; + hardware.graphics.enable = true; - nix.gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; - }; - - # Automatic Store Optimization - nix.settings.auto-optimise-store = true; - - environment.systemPackages = with pkgs; [ - git - wget - curl - vim - ]; + system.stateVersion = "25.11"; } diff --git a/newnix/hosts/home/nixos/flake.nix b/newnix/hosts/home/nixos/flake.nix deleted file mode 100644 index 84cea8f..0000000 --- a/newnix/hosts/home/nixos/flake.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ - description = "NixOS-WSL configuration for pan"; - - inputs = { - # Use nixos-unstable for latest packages - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - - # NixOS-WSL for WSL-specific functionality - nixos-wsl = { - url = "github:nix-community/NixOS-WSL"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - # Home Manager for user configuration - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = { self, nixpkgs, nixos-wsl, home-manager, ... }: - let - system = "x86_64-linux"; - in - { - nixosConfigurations = { - # Use your hostname: "nix" - nix = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - # NixOS-WSL module - nixos-wsl.nixosModules.wsl - - # System configuration - ./configuration.nix - - # Home Manager as NixOS module - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.pan = import ./home.nix; - } - ]; - }; - }; - }; -} diff --git a/newnix/hosts/home/nixos/home.nix b/newnix/hosts/home/nixos/home.nix new file mode 100644 index 0000000..3cb77d4 --- /dev/null +++ b/newnix/hosts/home/nixos/home.nix @@ -0,0 +1,13 @@ +{ config, pkgs, lib, ... }: + +{ + imports = [ + ../../../modules/home/common.nix + ]; + + # User details + home.username = "martin"; + home.homeDirectory = "/home/martin"; + + home.stateVersion = "25.11"; +} diff --git a/newnix/hosts/work/nix/home.nix b/newnix/hosts/work/nix/home.nix index 1e19b8e..a6dd15d 100644 --- a/newnix/hosts/work/nix/home.nix +++ b/newnix/hosts/work/nix/home.nix @@ -1,27 +1,25 @@ { config, pkgs, ... }: { + imports = [ + ../../../modules/home/common.nix + ../../../modules/home/llm.nix + ]; + home.username = "pan"; home.homeDirectory = "/home/pan"; - home.stateVersion = "23.11"; # Please read the comment before changing. + home.stateVersion = "23.11"; programs.git.settings.user = { name = "Martin Pander"; email = "martin.pander@knowtion.de"; }; - + programs.jujutsu.settings.user = { name = "Martin Pander"; email = "martin.pander@knowtion.de"; }; - - - home.packages = with pkgs; [ - yaml-language-server - marksman - dockerfile-language-server - ]; programs.zsh.profileExtra = '' source $HOME/.profile diff --git a/newnix/hosts/work/nixos/configuration.nix b/newnix/hosts/work/nixos/configuration.nix index 5aeca4c..45980b2 100644 --- a/newnix/hosts/work/nixos/configuration.nix +++ b/newnix/hosts/work/nixos/configuration.nix @@ -1,27 +1,15 @@ { config, lib, pkgs, ... }: { + imports = [ + ../../../modules/nixos/common.nix + ]; + wsl.enable = true; wsl.defaultUser = "pan"; wsl.interop.register = true; networking.hostName = "nix"; - #networking.networkmanager.enable = true; - - time.timeZone = "Europe/Berlin"; # Adjust to your timezone - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "de_DE.UTF-8"; - LC_IDENTIFICATION = "de_DE.UTF-8"; - LC_MEASUREMENT = "de_DE.UTF-8"; - LC_MONETARY = "de_DE.UTF-8"; - LC_NAME = "de_DE.UTF-8"; - LC_NUMERIC = "de_DE.UTF-8"; - LC_PAPER = "de_DE.UTF-8"; - LC_TELEPHONE = "de_DE.UTF-8"; - LC_TIME = "de_DE.UTF-8"; - }; users.users.pan = { isNormalUser = true; @@ -30,35 +18,5 @@ shell = pkgs.zsh; }; - programs.zsh.enable = true; - - nix.settings = { - experimental-features = [ "nix-command" "flakes" ]; - }; - - nixpkgs.config.allowUnfree = true; - - nix.gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; - }; - - # Automatic Store Optimization - nix.settings.auto-optimise-store = true; - - environment.systemPackages = with pkgs; [ - git - wget - curl - vim - ]; - - # This value determines the NixOS release from which the default - # settings for stateful data, like file locations and database versions - # on your system were taken. It's perfectly fine and recommended to leave - # this value at the release version of the first install of this system. - # Before changing this value read the documentation for this option - # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "25.05"; # Did you read the comment? + system.stateVersion = "25.05"; } diff --git a/newnix/hosts/work/nixos/flake.nix b/newnix/hosts/work/nixos/flake.nix deleted file mode 100644 index 84cea8f..0000000 --- a/newnix/hosts/work/nixos/flake.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ - description = "NixOS-WSL configuration for pan"; - - inputs = { - # Use nixos-unstable for latest packages - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - - # NixOS-WSL for WSL-specific functionality - nixos-wsl = { - url = "github:nix-community/NixOS-WSL"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - # Home Manager for user configuration - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = { self, nixpkgs, nixos-wsl, home-manager, ... }: - let - system = "x86_64-linux"; - in - { - nixosConfigurations = { - # Use your hostname: "nix" - nix = nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - # NixOS-WSL module - nixos-wsl.nixosModules.wsl - - # System configuration - ./configuration.nix - - # Home Manager as NixOS module - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.pan = import ./home.nix; - } - ]; - }; - }; - }; -} diff --git a/newnix/hosts/work/nixos/home.nix b/newnix/hosts/work/nixos/home.nix index a316b48..fd36068 100644 --- a/newnix/hosts/work/nixos/home.nix +++ b/newnix/hosts/work/nixos/home.nix @@ -2,12 +2,7 @@ { imports = [ - ./modules/home/default.nix - ./modules/tmux.nix - ./modules/git.nix - ./modules/dev.nix - ./modules/nvim.nix - ./modules/task.nix + ../../../modules/home/common.nix ]; # User details @@ -29,17 +24,8 @@ nix-ld ]; - # NIX_LD settings for running non-Nix binaries - # home.sessionVariables = { - # NIX_LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath [ - # stdenv.cc.cc - # zlib - # ]; - # NIX_LD = lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; - # }; - # This value determines the Home Manager release which the configuration is # compatible with. This helps avoid breakage when a new Home Manager release # introduces backwards incompatible changes. home.stateVersion = "25.05"; -} +} \ No newline at end of file diff --git a/newnix/modules/home/default.nix b/newnix/modules/home/common.nix similarity index 100% rename from newnix/modules/home/default.nix rename to newnix/modules/home/common.nix diff --git a/newnix/modules/home/dev.nix b/newnix/modules/home/dev.nix index e9edc05..384df76 100644 --- a/newnix/modules/home/dev.nix +++ b/newnix/modules/home/dev.nix @@ -9,6 +9,5 @@ home.packages = with pkgs; [ visidata - bubblewrap ]; } diff --git a/newnix/modules/home/llm.nix b/newnix/modules/home/llm.nix index cc00b09..81493b0 100644 --- a/newnix/modules/home/llm.nix +++ b/newnix/modules/home/llm.nix @@ -2,6 +2,7 @@ { home.packages = with pkgs; [ + bubblewrap claude-code opencode gemini-cli diff --git a/newnix/nixos/configuration.nix b/newnix/modules/nixos/common.nix similarity index 84% rename from newnix/nixos/configuration.nix rename to newnix/modules/nixos/common.nix index a3c08ce..bee8b77 100644 --- a/newnix/nixos/configuration.nix +++ b/newnix/modules/nixos/common.nix @@ -1,7 +1,7 @@ -{ config, lib, pkgs, ... }: +{ config, pkgs, lib, ... }: { - time.timeZone = "Europe/Berlin"; # Adjust to your timezone + time.timeZone = "Europe/Berlin"; i18n.defaultLocale = "en_US.UTF-8"; i18n.extraLocaleSettings = { @@ -20,6 +20,7 @@ nix.settings = { experimental-features = [ "nix-command" "flakes" ]; + auto-optimise-store = true; }; nixpkgs.config.allowUnfree = true; @@ -30,8 +31,6 @@ options = "--delete-older-than 7d"; }; - nix.settings.auto-optimise-store = true; - environment.systemPackages = with pkgs; [ git wget diff --git a/newnix/nix/flake.nix b/newnix/nix/flake.nix deleted file mode 100644 index c1fb70a..0000000 --- a/newnix/nix/flake.nix +++ /dev/null @@ -1,91 +0,0 @@ -{ - description = "Home Manager configuration of moustachioed"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - nix-darwin = { - url = "github:LnL7/nix-darwin"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = { self, nix-darwin, nixpkgs, home-manager, ... }: - let - #system = "x86_64-darwin"; - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - - configuration = { pkgs, ... }: { - environment.systemPackages = - [ - pkgs.vim - ]; - - # Auto upgrade nix package and the daemon service. - services.nix-daemon.enable = true; - # nix.package = pkgs.nix; - - nix.settings.experimental-features = "nix-command flakes"; - - programs.zsh.enable = true; # default shell on catalina - - # Set Git commit hash for darwin-version. - system.configurationRevision = self.rev or self.dirtyRev or null; - - # Used for backwards compatibility, please read the changelog before changing. - # $ darwin-rebuild changelog - system.stateVersion = 4; - - # The platform the configuration will be used on. - nixpkgs.hostPlatform = system; - }; - in { - # Build darwin flake using: - # $ darwin-rebuild build --flake .#Martins-MacBook-Pro - darwinConfigurations."Martins-MacBook-Pro" = nix-darwin.lib.darwinSystem { - modules = [ configuration ]; - }; - - # Expose the package set, including overlays, for convenience. - darwinPackages = self.darwinConfigurations."Martins-MacBook-Pro".pkgs; - - homeConfigurations = { - "moustachioed" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = [ - ./user/profiles/moustachioedBook.nix - ./common.nix - ./user/task_home.nix - ]; - }; - - "martin" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = [ - ./user/profiles/martin.nix - ./common.nix - ./user/task_home.nix - ]; - }; - - "pan" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - modules = [ - ./user/profiles/work.nix - ./common.nix - ./user/task.nix - { - nixpkgs.config.allowUnfree = true; - } - ]; - }; - }; - }; -} diff --git a/newnix/nix/martin.nix b/newnix/nix/martin.nix deleted file mode 100644 index 4f9fc00..0000000 --- a/newnix/nix/martin.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ config, pkgs, ... }: - -{ - home.username = "martin"; - home.homeDirectory = "/Users/martin"; - - home.stateVersion = "24.05"; # Please read the comment before changing. - - programs.git = { - userName = "Martin"; - userEmail = "git@pander-on.de"; - }; -}