492 lines
17 KiB
Nix
492 lines
17 KiB
Nix
{
|
|
description = "mads — NixOS for Apple Silicon (mbp) and x86 (pc), one flake";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
apple-silicon = {
|
|
url = "github:nix-community/nixos-apple-silicon";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
firefox-addons = {
|
|
url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
zen-browser = {
|
|
url = "github:0xc000022070/zen-browser-flake";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
inputs.home-manager.follows = "home-manager";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, apple-silicon, home-manager, firefox-addons, zen-browser, ... }:
|
|
let
|
|
home = { pkgs, osConfig, ... }: {
|
|
imports = [ zen-browser.homeModules.beta ];
|
|
home.stateVersion = "25.11";
|
|
|
|
programs.eww = {
|
|
enable = true;
|
|
package = pkgs.eww;
|
|
};
|
|
|
|
xdg.configFile = {
|
|
"hypr" = { source = ./config/hypr; recursive = true; };
|
|
"hypr/monitors.conf".text =
|
|
if osConfig.networking.hostName == "mbp"
|
|
then ''
|
|
monitor = , preferred, auto, 2.0
|
|
|
|
# Floating TUI panels: 70% wide, full height. Absolute px because
|
|
# Hyprland 0.56 ignores percentages in `size`. 1728x1080 logical.
|
|
windowrule = match:class ^(panel-wifi|panel-bt)$, float on, size 1210 1080, center on
|
|
''
|
|
else ''
|
|
monitor = desc:Lenovo Group Limited P27q-20 V909LRFR, 2560x1440@60, 0x0, 1.0
|
|
monitor = desc:Lenovo Group Limited P27q-20 V909LPNY, 2560x1440@60, 2560x0, 1.0
|
|
monitor = desc:Lenovo Group Limited P27q-20 V909LRDD, 2560x1440@60, 5120x0, 1.0
|
|
|
|
# Each screen's home workspace; SUPER+ALT+h/l can still move it.
|
|
workspace = 1, monitor:desc:Lenovo Group Limited P27q-20 V909LRFR, default:true
|
|
workspace = 2, monitor:desc:Lenovo Group Limited P27q-20 V909LPNY, default:true
|
|
workspace = 3, monitor:desc:Lenovo Group Limited P27q-20 V909LRDD, default:true
|
|
|
|
# Same panels, sized for 2560x1440 logical.
|
|
windowrule = match:class ^(panel-wifi|panel-bt)$, float on, size 1792 1440, center on
|
|
'';
|
|
"eww".source = ./config/eww;
|
|
"fuzzel".source = ./config/fuzzel;
|
|
};
|
|
|
|
home.file = {
|
|
".local/share/applications/nvim.desktop".text = ''
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=Neovim wrapper
|
|
NoDisplay=true
|
|
'';
|
|
".local/share/applications/uuctl.desktop".text = ''
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=uuctl
|
|
NoDisplay=true
|
|
'';
|
|
};
|
|
|
|
services.mako = {
|
|
enable = true;
|
|
settings = {
|
|
font = "JetBrainsMono Nerd Font 11";
|
|
background-color = "#16181a";
|
|
text-color = "#ffffff";
|
|
border-color = "#5ea1ff";
|
|
border-size = 2;
|
|
border-radius = 8;
|
|
default-timeout = 5000;
|
|
anchor = "top-right";
|
|
margin = "12";
|
|
padding = "12";
|
|
width = 380;
|
|
};
|
|
};
|
|
|
|
programs.kitty = {
|
|
enable = true;
|
|
settings = {
|
|
font_size = "11.5";
|
|
background = "#16181a";
|
|
foreground = "#ffffff";
|
|
cursor = "#ffffff";
|
|
cursor_text_color = "#16181a";
|
|
selection_background = "#3c4048";
|
|
selection_foreground = "#ffffff";
|
|
color0 = "#16181a";
|
|
color8 = "#3c4048";
|
|
color1 = "#ff6e5e";
|
|
color9 = "#ff6e5e";
|
|
color2 = "#5eff6c";
|
|
color10 = "#5eff6c";
|
|
color3 = "#f1ff5e";
|
|
color11 = "#f1ff5e";
|
|
color4 = "#5ea1ff";
|
|
color12 = "#5ea1ff";
|
|
color5 = "#bd5eff";
|
|
color13 = "#bd5eff";
|
|
color6 = "#5ef1ff";
|
|
color14 = "#5ef1ff";
|
|
color7 = "#ffffff";
|
|
color15 = "#ffffff";
|
|
active_tab_foreground = "#000000";
|
|
active_tab_background = "#ffbd5e";
|
|
inactive_tab_foreground = "#ffffff";
|
|
inactive_tab_background = "#16181a";
|
|
};
|
|
};
|
|
|
|
home.pointerCursor = {
|
|
enable = true;
|
|
package = pkgs.bibata-cursors;
|
|
name = "Bibata-Modern-Ice";
|
|
size = 24;
|
|
gtk.enable = true;
|
|
x11.enable = true;
|
|
hyprcursor.enable = true;
|
|
};
|
|
|
|
gtk = {
|
|
enable = true;
|
|
theme = { name = "Adwaita-dark"; package = pkgs.gnome-themes-extra; };
|
|
gtk3.extraConfig.gtk-application-prefer-dark-theme = 1;
|
|
gtk4.extraConfig.gtk-application-prefer-dark-theme = 1;
|
|
gtk4.theme = null;
|
|
};
|
|
|
|
programs.neovim = {
|
|
enable = true;
|
|
withPython3 = false;
|
|
withRuby = false;
|
|
withNodeJs = false;
|
|
initLua = builtins.readFile ./config/nvim/init.lua;
|
|
plugins = with pkgs.vimPlugins; [
|
|
nvim-web-devicons cyberdream-nvim oil-nvim nvim-lspconfig
|
|
typst-preview-nvim blink-cmp Navigator-nvim
|
|
snacks-nvim todo-comments-nvim trouble-nvim
|
|
nvim-treesitter.withAllGrammars
|
|
fidget-nvim lualine-nvim
|
|
];
|
|
extraPackages = with pkgs; [
|
|
lua-language-server rust-analyzer tinymist nixd zls
|
|
yaml-language-server vscode-langservers-extracted
|
|
typescript-language-server svelte-language-server
|
|
];
|
|
};
|
|
|
|
programs.zen-browser = {
|
|
enable = true;
|
|
setAsDefaultBrowser = true;
|
|
profiles.default = {
|
|
settings = {
|
|
"browser.newtabpage.enabled" = false;
|
|
"privacy.donottrackheader.enabled" = true;
|
|
"browser.theme.toolbar-theme" = 0;
|
|
"browser.theme.content-theme" = 0;
|
|
"layout.css.prefers-color-scheme.content-override" = 0;
|
|
"ui.systemUsesDarkTheme" = 1;
|
|
};
|
|
extensions.packages = let
|
|
addonsPkgs = import pkgs.path {
|
|
inherit (pkgs.stdenv.hostPlatform) system;
|
|
config.allowUnfree = true;
|
|
overlays = [ firefox-addons.overlays.default ];
|
|
};
|
|
in with addonsPkgs.firefox-addons; [
|
|
tridactyl
|
|
ublock-origin
|
|
onepassword-password-manager
|
|
];
|
|
};
|
|
};
|
|
|
|
programs.zsh = {
|
|
enable = true;
|
|
autosuggestion.enable = true;
|
|
syntaxHighlighting.enable = true;
|
|
shellAliases = { ll = "ls -alh"; gs = "git status"; };
|
|
};
|
|
programs.starship.enable = true;
|
|
|
|
programs.ssh = {
|
|
enable = true;
|
|
enableDefaultConfig = false;
|
|
settings."*".IdentityAgent = "~/.1password/agent.sock";
|
|
};
|
|
|
|
programs.git = {
|
|
enable = true;
|
|
settings = {
|
|
user.name = "Mads Fagerlund";
|
|
user.email = "mads@deepvis.ai";
|
|
user.signingkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAPlpVGZLhfrJqh2j5q3reyGOPQQ9BgW8syQ28tYjlg2";
|
|
gpg.format = "ssh";
|
|
"gpg \"ssh\"".program =
|
|
"${pkgs._1password-gui}/share/1password/op-ssh-sign";
|
|
commit.gpgsign = true;
|
|
url."git@git.deepvis.ai:".insteadOf = "https://git.deepvis.ai/";
|
|
};
|
|
};
|
|
|
|
home.packages = with pkgs; [ ripgrep fd tridactyl-native lazygit rustc cargo clippy rustfmt rust-analyzer claude-code gcc bluetui impala postgresql fastfetch (linearTui pkgs) ];
|
|
};
|
|
|
|
common = { pkgs, ... }: {
|
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
nix.settings.trusted-users = [ "mads" ];
|
|
nix.settings.extra-substituters = [ "https://deepvis.cachix.org" ];
|
|
nix.settings.extra-trusted-public-keys = [
|
|
"deepvis.cachix.org-1:UE/H6ERLwqhSqubzh8+pzl9eTm0kpMExGe0ym6fENp8="
|
|
];
|
|
nix.settings.netrc-file = "/etc/nix/netrc";
|
|
programs.ssh.knownHosts."builder" = {
|
|
extraHostNames = [ "5.9.71.104" "builder.tailf5eaab.ts.net" ];
|
|
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHnKIrxYtlovvYGgkpEZXY8wG/CuSLMGOM/84eIlyeVW";
|
|
};
|
|
programs.ssh.knownHosts."eu.nixbuild.net" = {
|
|
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPIQCZc54poJ8vqawd8TraNryQeJnvH1eLpIDgbiqymM";
|
|
};
|
|
nix.distributedBuilds = true;
|
|
nix.buildMachines = [
|
|
{
|
|
hostName = "builder";
|
|
sshUser = "builder";
|
|
sshKey = "/home/mads/.ssh/id_ed25519";
|
|
protocol = "ssh-ng";
|
|
system = "x86_64-linux";
|
|
maxJobs = 16;
|
|
supportedFeatures = [ "big-parallel" "kvm" "nixos-test" ];
|
|
}
|
|
];
|
|
|
|
networking.wireless.iwd.enable = true;
|
|
networking.useNetworkd = true;
|
|
systemd.network.wait-online.anyInterface = true;
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"C /var/lib/iwd/eduroam.8021x 0600 root root - ${pkgs.writeText "eduroam.8021x" ''
|
|
[Security]
|
|
EAP-Method=PEAP
|
|
EAP-Identity=447087@net.aau.dk
|
|
EAP-PEAP-Phase2-Method=MSCHAPV2
|
|
EAP-PEAP-Phase2-Identity=447087@net.aau.dk
|
|
''}"
|
|
];
|
|
|
|
services.gnome.gnome-keyring.enable = true;
|
|
programs._1password.enable = true;
|
|
programs._1password-gui = {
|
|
enable = true;
|
|
polkitPolicyOwners = [ "mads" ];
|
|
};
|
|
environment.etc."1password/custom_allowed_browsers".text = ''
|
|
zen-beta
|
|
'';
|
|
|
|
services.tailscale.enable = true;
|
|
services.tailscale.extraUpFlags = [ "--ssh" ];
|
|
|
|
time.timeZone = "Europe/Copenhagen"; # set yours
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
programs.hyprland = { enable = true; withUWSM = true; };
|
|
programs.hyprlock.enable = true;
|
|
|
|
systemd.user.services."wayland-wm@".serviceConfig.OOMPolicy = "continue";
|
|
|
|
security.pam.services.hyprlock.enableGnomeKeyring = true;
|
|
services.hypridle.enable = true;
|
|
|
|
systemd.user.services.caffeine = {
|
|
description = "Caffeine - inhibit idle, sleep and lid-switch";
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
ExecStart = "${pkgs.systemd}/bin/systemd-inhibit --what=idle:sleep:handle-lid-switch --who=caffeine --why=stay-awake --mode=block ${pkgs.coreutils}/bin/sleep infinity";
|
|
};
|
|
};
|
|
|
|
xdg.portal = {
|
|
enable = true;
|
|
extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
|
|
};
|
|
|
|
services.greetd = {
|
|
enable = true;
|
|
settings = {
|
|
initial_session = { user = "mads"; command = "uwsm start hyprland"; };
|
|
default_session = { user = "mads"; command = "uwsm start hyprland"; };
|
|
};
|
|
};
|
|
|
|
virtualisation.docker.enable = true;
|
|
|
|
hardware.bluetooth.enable = true;
|
|
programs.zsh.enable = true;
|
|
documentation.nixos.enable = false;
|
|
|
|
fonts.packages = [ pkgs.nerd-fonts.jetbrains-mono ];
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
git kitty fuzzel
|
|
wl-clipboard grim slurp swaybg brightnessctl playerctl hyprshot
|
|
hyprpolkitagent xdg-utils
|
|
|
|
(writeShellApplication {
|
|
name = "caffeine";
|
|
runtimeInputs = [ systemd ];
|
|
text = ''
|
|
unit=caffeine.service
|
|
|
|
is_on() { systemctl --user is-active --quiet "$unit"; }
|
|
|
|
# Guarded so `caffeine` still works over SSH / with no compositor.
|
|
toast() {
|
|
command -v hyprctl >/dev/null 2>&1 || return 0
|
|
hyprctl notify "$1" 2000 "$2" "$3" >/dev/null 2>&1 || true
|
|
}
|
|
|
|
wake_on() {
|
|
systemctl --user start "$unit"
|
|
toast 5 "rgb(5eff6c)" "Caffeine ON - idle, sleep and lid disabled"
|
|
}
|
|
|
|
wake_off() {
|
|
systemctl --user stop "$unit"
|
|
toast 1 "rgb(ff6e5e)" "Caffeine OFF - normal sleep restored"
|
|
}
|
|
|
|
case "''${1:-toggle}" in
|
|
toggle) if is_on; then wake_off; else wake_on; fi ;;
|
|
on) wake_on ;;
|
|
off) wake_off ;;
|
|
status) if is_on; then echo on; else echo off; fi ;;
|
|
*) echo "usage: caffeine [toggle|on|off|status]" >&2; exit 2 ;;
|
|
esac
|
|
'';
|
|
})
|
|
];
|
|
|
|
users.users.mads = {
|
|
isNormalUser = true;
|
|
extraGroups = [ "wheel" "video" "docker" ];
|
|
shell = pkgs.zsh;
|
|
initialPassword = "changeme";
|
|
};
|
|
|
|
system.stateVersion = "25.11";
|
|
home-manager.useGlobalPkgs = true;
|
|
home-manager.useUserPackages = true;
|
|
home-manager.backupFileExtension = "hm-bak";
|
|
home-manager.users.mads = home;
|
|
};
|
|
|
|
mkHost = { system, modules }: nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
modules = [
|
|
home-manager.nixosModules.home-manager
|
|
common
|
|
({ pkgs, ... }: {
|
|
nixpkgs.config.allowUnfree = true;
|
|
})
|
|
] ++ modules;
|
|
};
|
|
|
|
in
|
|
{
|
|
nixosConfigurations = {
|
|
mbp = mkHost {
|
|
system = "aarch64-linux";
|
|
modules = [
|
|
apple-silicon.nixosModules.apple-silicon-support
|
|
./hosts/mbp/hardware-configuration.nix
|
|
({ ... }: {
|
|
networking.hostName = "mbp";
|
|
hardware.asahi.peripheralFirmwareDirectory = ./firmware;
|
|
hardware.asahi.enable = true;
|
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
boot.loader.systemd-boot.configurationLimit = 3;
|
|
boot.extraModprobeConfig = "options hid_apple fnmode=1";
|
|
boot.blacklistedKernelModules = [ "pcspkr" ];
|
|
|
|
services.btrfs.autoScrub = {
|
|
enable = true;
|
|
interval = "monthly";
|
|
fileSystems = [ "/" ];
|
|
};
|
|
|
|
zramSwap = {
|
|
enable = true;
|
|
memoryPercent = 50;
|
|
};
|
|
|
|
boot.kernel.sysctl = {
|
|
"vm.swappiness" = 180;
|
|
"vm.page-cluster" = 0;
|
|
};
|
|
|
|
boot.binfmt.emulatedSystems = [ "x86_64-linux" ];
|
|
|
|
services.avahi = {
|
|
enable = true;
|
|
nssmdns4 = true;
|
|
};
|
|
services.resolved.settings.Resolve.MulticastDNS = false;
|
|
|
|
nix.settings = {
|
|
extra-substituters = [
|
|
"https://nixos-apple-silicon.cachix.org"
|
|
"https://nixos-raspberrypi.cachix.org"
|
|
];
|
|
extra-trusted-public-keys = [
|
|
"nixos-apple-silicon.cachix.org-1:8psDu5SA5dAD7qA0zMy5UT292TxeEPzIz8VVEr2Js20="
|
|
"nixos-raspberrypi.cachix.org-1:4iMO9LXa8BqhU+Rpg6LQKiGa2lsNh/j2oiYLNOQ5sPI="
|
|
];
|
|
};
|
|
})
|
|
];
|
|
};
|
|
|
|
pc = mkHost {
|
|
system = "x86_64-linux";
|
|
modules = [
|
|
./hosts/pc/hardware-configuration.nix
|
|
({ config, ... }: {
|
|
networking.hostName = "pc";
|
|
|
|
networking.interfaces.enp7s0 = {
|
|
useDHCP = false;
|
|
ipv4.addresses = [ { address = "192.168.12.1"; prefixLength = 24; } ];
|
|
};
|
|
systemd.network.networks."40-enp7s0" = {
|
|
networkConfig.IPv6AcceptRA = false;
|
|
networkConfig.ConfigureWithoutCarrier = true;
|
|
linkConfig.RequiredForOnline = "no";
|
|
};
|
|
boot.loader.systemd-boot.enable = true;
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
systemd.sleep.settings.Sleep = {
|
|
AllowSuspend = "no";
|
|
AllowHibernation = "no";
|
|
AllowHybridSleep = "no";
|
|
AllowSuspendThenHibernate = "no";
|
|
};
|
|
services.logind.suspendKey = "ignore";
|
|
services.logind.hibernateKey = "ignore";
|
|
services.logind.lidSwitch = "ignore";
|
|
|
|
services.xserver.videoDrivers = [ "nvidia" ];
|
|
hardware.graphics.enable = true;
|
|
hardware.nvidia = {
|
|
modesetting.enable = true;
|
|
open = true;
|
|
nvidiaSettings = true;
|
|
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
|
};
|
|
})
|
|
];
|
|
};
|
|
};
|
|
|
|
devShells = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" ] (system: {
|
|
default = nixpkgs.legacyPackages.${system}.mkShell {
|
|
packages = [ nixpkgs.legacyPackages.${system}.nodejs ];
|
|
};
|
|
});
|
|
};
|
|
}
|