Refactor nix config

This commit is contained in:
Martin Pander
2026-02-06 21:41:49 +01:00
parent 8ca8d55826
commit 744cb9eb0d
17 changed files with 156 additions and 347 deletions

21
newnix/flake.lock generated
View File

@@ -36,6 +36,26 @@
"type": "github" "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": { "nixos-wsl": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
@@ -76,6 +96,7 @@
"root": { "root": {
"inputs": { "inputs": {
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixos-wsl": "nixos-wsl", "nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }

View File

@@ -1,44 +1,88 @@
{ {
description = "NixOS Shared Configuration"; description = "Unified Nix Configuration";
inputs = { inputs = {
# Use nixos-unstable for latest packages
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# NixOS-WSL for WSL-specific functionality
nixos-wsl = { nixos-wsl = {
url = "github:nix-community/NixOS-WSL"; url = "github:nix-community/NixOS-WSL";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# Home Manager for user configuration
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; 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 let
system = "x86_64-linux"; linuxSystem = "x86_64-linux";
darwinSystem = "aarch64-darwin";
pkgsLinux = nixpkgs.legacyPackages.${linuxSystem};
pkgsDarwin = nixpkgs.legacyPackages.${darwinSystem};
in in
{ {
# --- NixOS Systems ---
nixosConfigurations = { nixosConfigurations = {
nix = nixpkgs.lib.nixosSystem {
inherit system; # Work WSL
work = nixpkgs.lib.nixosSystem {
system = linuxSystem;
specialArgs = { inherit self; };
modules = [ modules = [
nixos-wsl.nixosModules.wsl nixos-wsl.nixosModules.wsl
./hosts/work/nixos/configuration.nix
./hosts/work/configuration.nix
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = 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 ];
};
};
}; };
} }

View File

@@ -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";
}

View File

@@ -1,13 +1,22 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = [
../../../modules/home/common.nix
];
home.username = "martin"; home.username = "martin";
home.homeDirectory = "/Users/martin"; home.homeDirectory = "/Users/martin";
home.stateVersion = "24.05"; # Please read the comment before changing. home.stateVersion = "24.05";
programs.git = { programs.git.settings.user = {
userName = "Martin"; name = "Martin Pander";
userEmail = "git@pander-on.de"; email = "git@pander-on.de";
};
programs.jujutsu.settings.user = {
name = "Martin Pander";
email = "git@pander-on.de";
}; };
} }

View File

@@ -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, ... }: { config, lib, pkgs, ... }:
{ {
wsl.enable = true; imports = [
wsl.defaultUser = "pan"; ../../../modules/nixos/common.nix
wsl.interop.register = true; ];
# This value determines the NixOS release from which the default boot.loader.systemd-boot.enable = true;
# settings for stateful data, like file locations and database versions boot.loader.efi.canTouchEfiVariables = true;
# 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?
networking.hostName = "nix"; fileSystems."/" = {
#networking.networkmanager.enable = true; device = "/dev/disk/by-label/nixos";
fsType = "ext4";
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 = { networking.hostName = "macnix";
users.users.martin = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "networkmanager" "wheel" ]; extraGroups = [ "networkmanager" "wheel" ];
uid = 1000; uid = 1000;
shell = pkgs.zsh; shell = pkgs.zsh;
}; };
programs.zsh.enable = true; services.spice-vdagentd.enable = true;
services.qemuGuest.enable = true;
nix.settings = { services.xserver.videoDrivers = [ "virtio" ];
experimental-features = [ "nix-command" "flakes" ];
};
nixpkgs.config.allowUnfree = true; hardware.graphics.enable = true;
nix.gc = { system.stateVersion = "25.11";
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
];
} }

View File

@@ -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;
}
];
};
};
};
}

View File

@@ -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";
}

View File

@@ -1,27 +1,25 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = [
../../../modules/home/common.nix
../../../modules/home/llm.nix
];
home.username = "pan"; home.username = "pan";
home.homeDirectory = "/home/pan"; home.homeDirectory = "/home/pan";
home.stateVersion = "23.11"; # Please read the comment before changing. home.stateVersion = "23.11";
programs.git.settings.user = { programs.git.settings.user = {
name = "Martin Pander"; name = "Martin Pander";
email = "martin.pander@knowtion.de"; email = "martin.pander@knowtion.de";
}; };
programs.jujutsu.settings.user = { programs.jujutsu.settings.user = {
name = "Martin Pander"; name = "Martin Pander";
email = "martin.pander@knowtion.de"; email = "martin.pander@knowtion.de";
}; };
home.packages = with pkgs; [
yaml-language-server
marksman
dockerfile-language-server
];
programs.zsh.profileExtra = '' programs.zsh.profileExtra = ''
source $HOME/.profile source $HOME/.profile

View File

@@ -1,27 +1,15 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ {
imports = [
../../../modules/nixos/common.nix
];
wsl.enable = true; wsl.enable = true;
wsl.defaultUser = "pan"; wsl.defaultUser = "pan";
wsl.interop.register = true; wsl.interop.register = true;
networking.hostName = "nix"; 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 = { users.users.pan = {
isNormalUser = true; isNormalUser = true;
@@ -30,35 +18,5 @@
shell = pkgs.zsh; shell = pkgs.zsh;
}; };
programs.zsh.enable = true; system.stateVersion = "25.05";
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?
} }

View File

@@ -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;
}
];
};
};
};
}

View File

@@ -2,12 +2,7 @@
{ {
imports = [ imports = [
./modules/home/default.nix ../../../modules/home/common.nix
./modules/tmux.nix
./modules/git.nix
./modules/dev.nix
./modules/nvim.nix
./modules/task.nix
]; ];
# User details # User details
@@ -29,17 +24,8 @@
nix-ld 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 # This value determines the Home Manager release which the configuration is
# compatible with. This helps avoid breakage when a new Home Manager release # compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes. # introduces backwards incompatible changes.
home.stateVersion = "25.05"; home.stateVersion = "25.05";
} }

View File

@@ -9,6 +9,5 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
visidata visidata
bubblewrap
]; ];
} }

View File

@@ -2,6 +2,7 @@
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
bubblewrap
claude-code claude-code
opencode opencode
gemini-cli gemini-cli

View File

@@ -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.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = { i18n.extraLocaleSettings = {
@@ -20,6 +20,7 @@
nix.settings = { nix.settings = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [ "nix-command" "flakes" ];
auto-optimise-store = true;
}; };
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@@ -30,8 +31,6 @@
options = "--delete-older-than 7d"; options = "--delete-older-than 7d";
}; };
nix.settings.auto-optimise-store = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
git git
wget wget

View File

@@ -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;
}
];
};
};
};
}

View File

@@ -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";
};
}