1
0

Update and simplify the nix configuration

This commit is contained in:
Jip J. Dekker 2025-01-14 20:34:03 +11:00
parent 33cb1c5488
commit 4953bc3e75
No known key found for this signature in database
25 changed files with 192 additions and 369 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
result

View File

@ -1,22 +0,0 @@
#!/bin/sh -e
VERSION=1.0
export args=$@
# Navigate to the directory of this script
cd $(dirname $(readlink -f $0))
cd ..
SYSTEM=$(uname)
build() {
if [ $SYSTEM == "Darwin" ]; then
./bin/darwin-build $args
elif [ $SYSTEM == "Linux" ]; then
./bin/nixos-build $args
else
echo "Unknown platform"
fi
}
build

View File

@ -1,27 +0,0 @@
#!/bin/sh -e
VERSION=1.0
GREEN='\033[1;32m'
RED='\033[1;31m'
NC='\033[0m'
FLAKE="macos"
SYSTEM="darwinConfigurations.$FLAKE.system"
export NIXPKGS_ALLOW_UNFREE=1
# Navigate to the directory of this script
cd $(dirname $(readlink -f $0))
cd ..
echo "${GREEN}Starting build...${NC}"
nix --experimental-features 'nix-command flakes' build .#$SYSTEM $@
echo "${GREEN}Switching to new generation...${NC}"
./result/sw/bin/darwin-rebuild switch --flake .#$FLAKE $@
echo "${GREEN}Cleaning up...${NC}"
unlink ./result
echo "${GREEN}Switch to new generation complete!${NC}"

View File

@ -1,29 +0,0 @@
#!/bin/sh -e
VERSION=1.0
GREEN='\033[1;32m'
RED='\033[1;31m'
NC='\033[0m'
SYSTEM=$(uname -m)
case "$SYSTEM" in
x86_64)
FLAKE_TARGET="x86_64-linux"
;;
aarch64)
FLAKE_TARGET="aarch64-linux"
;;
*)
echo -e "${RED}Unsupported architecture: $SYSTEM${NC}"
exit 1
;;
esac
echo -e "${GREEN}Starting...${NC}"
# We pass SSH from user to root so root can download secrets from your private Github
sudo SSH_AUTH_SOCK=$SSH_AUTH_SOCK /run/current-system/sw/bin/nixos-rebuild switch --flake .#$FLAKE_TARGET $@
echo -e "${GREEN}Switch to new generation complete!${NC}"

View File

@ -1,11 +0,0 @@
## Layout
```
.
├── dock # MacOS dock configuration
├── casks.nix # List of homebrew casks
├── default.nix # Defines module, system-level config
├── files.nix # Non-Nix, static configuration files (now immutable!)
├── home-manager.nix # Defines user programs
├── packages.nix # List of packages to install for MacOS
```

View File

@ -1,5 +1,4 @@
{}:
[
# Development Tools
"docker"
@ -7,7 +6,6 @@
"qflipper"
"sublime-merge"
"vscodium"
"warp"
"zed"
# Communication Tools

View File

@ -1,7 +1,4 @@
{ config, pkgs, ... }:
let user = "dekker1"; in
{ pkgs, user, ... }:
{
imports = [
./home-manager.nix
@ -9,9 +6,6 @@ let user = "dekker1"; in
../shared/cachix
];
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# Setup user, packages, programs
nix = {
package = pkgs.nix;
@ -34,20 +28,116 @@ let user = "dekker1"; in
system.checks.verifyNixPath = false;
# Load configuration that is shared across systems
environment.systemPackages = with pkgs; [
] ++ (import ../shared/packages.nix { inherit pkgs; });
environment.systemPackages = import ../shared/packages.nix { inherit pkgs; } ++ [
# MacOS specific packages
];
# Setup MacOS specific services
services = {
yabai = {
aerospace = {
enable = true;
extraConfig = (builtins.readFile ./config/yabairc);
settings = {
mode.main.binding = {
# Open a new terminal window
alt-enter = "exec-and-forget /Users/dekker1/.nix-profile/bin/kitty --single-instance -d ~";
# alt-enter = "exec-and-forget open \"warp://action/new_window?path=$HOME\"";
# Toggle between floating and tiling layout
alt-shift-space = "layout floating tiling";
### Key mappings copied from the default config
# See: https://nikitabobko.github.io/AeroSpace/commands#layout
alt-slash = "layout tiles horizontal vertical";
alt-comma = "layout accordion horizontal vertical";
# See: https://nikitabobko.github.io/AeroSpace/commands#focus
alt-h = "focus left";
alt-j = "focus down";
alt-k = "focus up";
alt-l = "focus right";
# See: https://nikitabobko.github.io/AeroSpace/commands#move
alt-shift-h = "move left";
alt-shift-j = "move down";
alt-shift-k = "move up";
alt-shift-l = "move right";
# See: https://nikitabobko.github.io/AeroSpace/commands#resize
alt-shift-minus = "resize smart -50";
alt-shift-equal = "resize smart +50";
# See: https://nikitabobko.github.io/AeroSpace/commands#workspace
alt-1 = "workspace 1";
alt-2 = "workspace 2";
alt-3 = "workspace 3";
alt-4 = "workspace 4";
alt-5 = "workspace 5";
alt-6 = "workspace 6";
alt-7 = "workspace 7";
alt-8 = "workspace 8";
alt-9 = "workspace 9";
# See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace
alt-shift-1 = "move-node-to-workspace 1";
alt-shift-2 = "move-node-to-workspace 2";
alt-shift-3 = "move-node-to-workspace 3";
alt-shift-4 = "move-node-to-workspace 4";
alt-shift-5 = "move-node-to-workspace 5";
alt-shift-6 = "move-node-to-workspace 6";
alt-shift-7 = "move-node-to-workspace 7";
alt-shift-8 = "move-node-to-workspace 8";
alt-shift-9 = "move-node-to-workspace 9";
# See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth
alt-tab = "workspace-back-and-forth";
# See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor
alt-shift-tab = "move-workspace-to-monitor --wrap-around next";
# See: https://nikitabobko.github.io/AeroSpace/commands#mode
alt-shift-semicolon = "mode service";
};
### Service mode (from default config, with default keybindings)
mode.service.binding = {
esc = ["reload-config" "mode main"];
r = ["flatten-workspace-tree" "mode main"]; # reset layout
f = ["layout floating tiling" "mode main"]; # Toggle between floating and tiling layout
backspace = ["close-all-windows-but-current" "mode main"];
# sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2
#s = ["layout sticky tiling", "mode main"]
alt-shift-h = ["join-with left" "mode main"];
alt-shift-j = ["join-with down" "mode main"];
alt-shift-k = ["join-with up" "mode main"];
alt-shift-l = ["join-with right" "mode main"];
## Version 0.16+
# down = "volume down";
# up = "volume up";
# shift-down = ["volume set 0" "mode main"];
};
# on-window-detected = [
# # Use floating mode for Sublime Merge
# {
# "if.app-id" = "com.sublimemerge";
# run = "layout floating";
# }
# ];
};
};
# Auto upgrade nix package and the daemon service.
nix-daemon.enable = true;
skhd = {
enable = true;
enable = false;
skhdConfig = (builtins.readFile ./config/skhdrc);
};
yabai = {
enable = false;
extraConfig = (builtins.readFile ./config/yabairc);
};
};
system.stateVersion = 5;

View File

@ -1,8 +0,0 @@
{ user, config, pkgs, ... }:
let
xdg_configHome = "${config.users.users.${user}.home}/.config";
xdg_dataHome = "${config.users.users.${user}.home}/.local/share";
xdg_stateHome = "${config.users.users.${user}.home}/.local/state";
in
{ }

View File

@ -1,10 +1,4 @@
{ config, pkgs, lib, home-manager, ... }:
let
user = "dekker1";
sharedFiles = import ../shared/files.nix { inherit config pkgs; };
additionalFiles = import ./files.nix { inherit user config pkgs; };
in
{ email, name, pkgs, sshSignKey, user, ... }:
{
# It me
users.users.${user} = {
@ -24,6 +18,16 @@ in
casks = pkgs.callPackage ./casks.nix { };
brews = [
"openssl" # Required by cargo-update (`LDFLAGS="-L/usr/local/opt/openssl@3/lib" CPPFLAGS="-I/usr/local/opt/openssl@3/include" cargo install cargo-update`)
# MiniZinc solvers
"dekker1/minizinc/choco"
"dekker1/minizinc/flatzingo"
"dekker1/minizinc/geas"
"dekker1/minizinc/jacop"
"dekker1/minizinc/fzn-oscar-cbls"
"dekker1/minizinc/fzn-picat"
"dekker1/minizinc/pumpkin"
"dekker1/minizinc/yuck"
"scip"
];
taps = [
@ -58,24 +62,16 @@ in
useGlobalPkgs = true;
users.${user} = { pkgs, config, lib, ... }: {
home.enableNixpkgsReleaseCheck = false;
home.packages = pkgs.callPackage ./packages.nix { };
home.file = lib.mkMerge [
sharedFiles
additionalFiles
];
home.stateVersion = "21.11";
programs = {
programs = lib.attrsets.recursiveUpdate (import ../shared/home-manager.nix {
inherit config email lib name pkgs sshSignKey user;
}) {
# MacOS specific home-manager program settings
git.extraConfig.gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
skim.enable = true;
ssh.matchBlocks = {
"*" = {
extraOptions = {
"UseKeychain" = "yes";
};
};
};
} // import ../shared/home-manager.nix {
inherit config pkgs lib;
ssh.matchBlocks."*".extraOptions."UseKeychain" = "yes";
};
};
};

View File

@ -1,8 +0,0 @@
{ pkgs }:
with pkgs;
let shared-packages = import ../shared/packages.nix { inherit pkgs; }; in
shared-packages ++ [
# Encryption and security tools
pinentry_mac
]

24
flake.lock generated
View File

@ -7,16 +7,16 @@
]
},
"locked": {
"lastModified": 1731153869,
"narHash": "sha256-3Ftf9oqOypcEyyrWJ0baVkRpvQqroK/SVBFLvU3nPuc=",
"lastModified": 1736820923,
"narHash": "sha256-SDuKLOWAh8VJRXlNWQn9QE99bjeEUAAbYXqrKGbsiyk=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "5c74ab862c8070cbf6400128a1b56abb213656da",
"rev": "944c2b181792ae7ae6b20c0df3f44879c11706c9",
"type": "github"
},
"original": {
"owner": "LnL7",
"ref": "master",
"ref": "nix-darwin-24.11",
"repo": "nix-darwin",
"type": "github"
}
@ -28,32 +28,32 @@
]
},
"locked": {
"lastModified": 1726989464,
"narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=",
"lastModified": 1736373539,
"narHash": "sha256-dinzAqCjenWDxuy+MqUQq0I4zUSfaCvN9rzuCmgMZJY=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176",
"rev": "bd65bc3cde04c16755955630b344bc9e35272c56",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-24.05",
"ref": "release-24.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1730891215,
"narHash": "sha256-i85DPrhDuvzgvIWCpJlbfM2UFtNYbapo20MtQXsvay4=",
"lastModified": 1736780541,
"narHash": "sha256-6AwU5WC45Ww5q5qVR/AzKS4CeZzgOhclBKi5H7zrCnI=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c128e44a249d6180740d0a979b6480d5b795c013",
"rev": "31206f5a1d081808b14aef7b48f7c214d902b8c0",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-24.05-darwin",
"ref": "nixpkgs-24.11-darwin",
"repo": "nixpkgs",
"type": "github"
}

View File

@ -2,62 +2,53 @@
description = "Dekker1's home manager configuation";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-24.05-darwin";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-24.11-darwin";
home-manager = {
url = "github:nix-community/home-manager/release-24.05";
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:LnL7/nix-darwin/master";
url = "github:LnL7/nix-darwin/nix-darwin-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, darwin
{ darwin
, home-manager
, nixpkgs
} @inputs:
, ...
} @ inputs:
let
user = "dekker1";
# Systems that can be used
linuxSystems = [ "x86_64-linux" "aarch64-linux" ];
darwinSystems = [ "aarch64-darwin" ];
forAllLinuxSystems = f: nixpkgs.lib.genAttrs linuxSystems (system: f system);
forAllDarwinSystems = f: nixpkgs.lib.genAttrs darwinSystems (system: f system);
forAllSystems = f: nixpkgs.lib.genAttrs (linuxSystems ++ darwinSystems) (system: f system);
devShell = system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = with pkgs; mkShell {
nativeBuildInputs = with pkgs; [ bashInteractive git ];
shellHook = with pkgs; ''
'';
};
};
darwinSystems = [ "aarch64-darwin" "x86_64-darwin" ];
# Arguments that are passed into the system configuration
name = "Jip J. Dekker";
email = "jip@dekker.one";
sshSignKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMCC0liW47USr/Ic1rJ52V4eE07y42VG9Ols1zYBrPlc";
user = "dekker1";
# Special arguments that are passed into each system configuration
specialArgs = inputs // { inherit email name sshSignKey user; };
in
{
devShells = forAllSystems devShell;
darwinConfigurations = let user = "dekker1"; in {
macos = darwin.lib.darwinSystem {
system = "aarch64-darwin";
specialArgs = inputs;
modules = [
home-manager.darwinModules.home-manager
./darwin
];
};
};
darwinConfigurations = nixpkgs.lib.genAttrs darwinSystems (system:
darwin.lib.darwinSystem {
inherit system specialArgs;
modules = [
home-manager.darwinModules.home-manager
./darwin
];
}
);
nixosConfigurations = nixpkgs.lib.genAttrs linuxSystems (system: nixpkgs.lib.nixosSystem {
system = system;
specialArgs = inputs;
inherit system specialArgs;
modules = [
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${user} = import ./nixos/home-manager.nix;
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = import ./nixos/home-manager.nix;
};
}
./nixos
];

View File

@ -1,9 +0,0 @@
## Layout
```
.
├── config # Config files not written in Nix
├── default.nix # Defines module, system-level config,
├── files.nix # Non-Nix, static configuration files (now immutable!)
├── home-manager.nix # Defines user programs
├── packages.nix # List of packages to install for NixOS
```

View File

@ -1,9 +1,4 @@
{ config, inputs, pkgs, ... }:
let
user = "dekker1";
keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICwXNVel0w1f4nbmu2iJsqCoeiUsENzTLyhCZjSL+jT+" ];
in
{ pkgs, user, ... }:
{
imports = [
../shared
@ -30,18 +25,12 @@ in
"wheel" # Enable sudo for the user.
];
shell = pkgs.zsh;
openssh.authorizedKeys.keys = keys;
};
# My shell
programs.zsh.enable = true;
fonts.packages = with pkgs; [
];
environment.systemPackages = with pkgs; [
environment.systemPackages = import ../shared/packages.nix { inherit pkgs; } ++ (with pkgs; [
# Linux specific packages
gitAndTools.gitFull
];
]);
system.stateVersion = "21.05"; # Don't change this

View File

@ -1,9 +0,0 @@
{ user, pkgs, ... }:
let
home = builtins.getEnv "HOME";
xdg_configHome = "${home}/.config";
xdg_dataHome = "${home}/.local/share";
xdg_stateHome = "${home}/.local/state";
in
{ }

View File

@ -1,26 +1,18 @@
{ config, pkgs, lib, ... }:
let
user = "dekker1";
xdg_configHome = "/home/${user}/.config";
shared-programs = import ../shared/home-manager.nix { inherit config pkgs lib; };
shared-files = import ../shared/files.nix { inherit config pkgs; };
in
{ config, email, lib, name, pkgs, sshSignKey, user, ... }:
{
home = {
enableNixpkgsReleaseCheck = false;
username = "${user}";
homeDirectory = "/home/${user}";
packages = // pkgs.callPackage ./packages.nix { };
file = shared-files // import ./files.nix { inherit user; };
stateVersion = "21.05";
};
programs = {
programs = lib.attrsets.recursiveUpdate (import ../shared/home-manager.nix {
inherit config email lib name pkgs sshSignKey user;
}) {
firefox = {
enable = true;
package = pkgs.firefox-bin;
};
} // shared-programs;
};
}

View File

@ -1,8 +0,0 @@
{ pkgs }:
with pkgs;
let shared-packages = import ../shared/packages.nix { inherit pkgs; }; in
shared-packages ++ [
# Encryption and security tools
pinentry
]

View File

@ -1,6 +0,0 @@
# Overlays
Files in this directory run automatically as part of each build. Some common ways I've used overlays in the past:
* Applying patches
* Downloading different versions of files (locking to a version or trying a fork)
* Workarounds and stuff I need to run temporarily

View File

@ -1,16 +0,0 @@
## Shared
Much of the code running on MacOS or NixOS is actually found here.
This configuration gets imported by both modules. Some configuration examples include `git`, `zsh`, `vim`, and `tmux`.
## Layout
```
.
├── config # Config files not written in Nix
├── cachix # Defines cachix, a global cache for builds
├── default.nix # Defines how we import overlays
├── files.nix # Non-Nix, static configuration files (now immutable!)
├── home-manager.nix # The goods; most all shared config lives here
├── packages.nix # List of packages to share
```

View File

@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ ... }:
{
nix.settings = {
substituters = [

View File

@ -1,46 +0,0 @@
# vim:ft=kitty
## name: Night Owl
## author: Luke Glazebrook <lukeglazebrook@hey.com>
## license: MIT
foreground #d6deeb
background #011627
selection_foreground none
selection_background #1d3b53
#: Cursor colors
cursor #80a4c2
cursor_text_color background
#: The basic 16 colors
#: black
color0 #011627
color8 #575656
#: red
color1 #ef5350
color9 #ef5350
#: green
color2 #22da6e
color10 #22da6e
#: yellow
color3 #addb67
color11 #ffeb95
#: blue
color4 #82aaff
color12 #82aaff
#: magenta
color5 #c792ea
color13 #c792ea
#: cyan
color6 #21c7a8
color14 #7fdbca
#: white
color7 #ffffff
color15 #ffffff

View File

@ -1,7 +1,5 @@
{ config, pkgs, ... }:
{ ... }:
{
nixpkgs = {
config = {
allowUnfree = true;
@ -9,14 +7,5 @@
allowInsecure = false;
allowUnsupportedSystem = true;
};
overlays =
# Apply each overlay found in the /overlays directory
let path = ../overlays; in with builtins;
map (n: import (path + ("/" + n)))
(filter
(n: match ".*\\.nix" n != null ||
pathExists (path + ("/" + n + "/default.nix")))
(attrNames (readDir path)));
};
}

View File

@ -1,9 +0,0 @@
{ pkgs, config, ... }:
{
".config/kitty/themes/night-owl.conf" = {
text = builtins.readFile ../shared/config/kitty/night-owl.conf;
};
}

View File

@ -1,11 +1,9 @@
{ config, pkgs, lib, ... }:
{ pkgs, email, name, sshSignKey, ... }:
let
name = "Jip J. Dekker";
user = "dekker1";
email = "jip@dekker.one";
in
{
atuin.enable = true;
bat.enable = true;
direnv = {
@ -65,30 +63,35 @@ in
commit.gpgsign = true;
gpg.format = "ssh";
user.signingkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMCC0liW47USr/Ic1rJ52V4eE07y42VG9Ols1zYBrPlc";
gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
user.signingkey = sshSignKey;
};
};
jujutsu = {
enable = true;
settings = {
email = "jip@dekker.one";
name = "Jip J. Dekker";
signing = {
sign-all = true;
backend = "ssh";
key = sshSignKey;
};
user = { inherit email name; };
ui.editor = "zed -w";
};
};
kitty = {
darwinLaunchOptions = [ "--single-instance" ];
enable = true;
font = {
name = "JetBrainsMono Nerd Font";
name = "Berkeley Mono Variable Nerd Font";
size = 14;
};
settings = {
cursor_shape = "underline";
confirm_os_window_close = 0;
};
theme = "GitHub Light";
themeFile = "Catppuccin-Latte";
};
# Shared shell configuration
@ -165,19 +168,6 @@ in
'';
};
# sapling = {
# enable = true;
# userName = "Jip J. Dekker";
# userEmail = "jip@dekker.one";
# extraConfig = {
# ui."ignore.userroot" = "~/.config/git/ignore";
# isl = {
# hasShownGettingStarted = false;
# render-compact = false;
# };
# };
# };
ssh = {
enable = true;
matchBlocks = {
@ -208,7 +198,7 @@ in
settings = {
misc.disable = [
"brew_cask"
"brew_formula"
# "brew_formula"
"containers"
"gem"
"node"
@ -222,7 +212,7 @@ in
misc.cleanup = true;
misc.no_retry = true;
pre_commands = {
"Home Manager" = "(cd ~/nix-config/ && nix flake update) && ~/nix-config/bin/build";
"Home Manager" = "(cd ~/nix-config/ && nix flake update) && darwin-rebuild switch --flake ~/nix-config#aarch64-darwin";
};
};
};
@ -260,7 +250,6 @@ in
RUSTC_WRAPPER = "sccache";
};
initExtra = ''
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
# Load Homebrew shell environment
if [[ -f "/opt/homebrew/bin/brew" && -x $(realpath "/opt/homebrew/bin/brew") ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
@ -268,8 +257,5 @@ in
eval "$(/usr/local/bin/brew shellenv)"
fi
'';
historySubstringSearch = {
enable = true;
};
};
}

View File

@ -1,5 +1,4 @@
{ pkgs }:
with pkgs; [
# General packages for development and system management
hut
@ -35,7 +34,7 @@ with pkgs; [
# Python development tools
black
poetry
uv
# Rust development tools
rustup