Restructuring #1

Merged
Jan merged 16 commits from blueprint into main 2025-05-28 10:41:45 +00:00
42 changed files with 2205 additions and 144 deletions
Showing only changes of commit 5e23488cae - Show all commits

60
flake.lock generated Normal file
View File

@ -0,0 +1,60 @@
{
"nodes": {
"glue": {
"locked": {
"path": "./glue",
"type": "path"
},
"original": {
"path": "./glue",
"type": "path"
},
"parent": []
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1746981801,
"narHash": "sha256-+Bfr0KqZV6gZdA7e2kupeoawozaLIHLuiPtC54uxbFc=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "ff915842e4a2e63c4c8c5c08c6870b9d5b3c3ee9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1746576598,
"narHash": "sha256-FshoQvr6Aor5SnORVvh/ZdJ1Sa2U4ZrIMwKBX5k2wu0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b3582c75c7f21ce0b429898980eddbbf05c68e55",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"glue": "glue",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,88 +1,12 @@
{
description = "NixOS system";
description = "System configuration for NixOS";
inputs = {
glue.url = "./glue";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
stylix.url = "github:danth/stylix";
nixvim.url = "github:nix-community/nixvim";
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-matlab = {
url = "gitlab:doronbehar/nix-matlab";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{
self,
nixpkgs,
home-manager,
stylix,
nixvim,
nur,
nix-matlab,
nixos-cosmic,
...
}:
let
mkConfig =
system: machineConfig: userConfig:
(nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit system; };
modules = [
machineConfig
home-manager.nixosModules.home-manager
{
nix.settings = {
substituters = [ "https://cosmic.cachix.org/" ];
trusted-public-keys = [ "cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE=" ];
};
machine.users = userConfig;
home-manager.extraSpecialArgs = { inherit system; };
home-manager.sharedModules = [
stylix.homeManagerModules.stylix
nixvim.homeManagerModules.nixvim
nur.modules.homeManager.default
{
nixpkgs.overlays = [
nix-matlab.overlay
nixos-cosmic.overlays.default
];
}
];
}
];
});
in
{
nixosConfigurations = {
"20212060" = mkConfig "x86_64-linux" ./machines/laptop.nix {
jan = {
sudo = true;
configuration = ./users/jan.nix;
};
berg-van-abstractie = {
sudo = false;
configuration = ./users/comp-prog.nix;
};
};
"vm-audio" = mkConfig "x86_64-linux" ./machines/vm-audio.nix {
local = {
sudo = true;
configuration = ./users/server.nix;
};
};
};
lib = import ./shell-modules/default.nix self.inputs;
};
outputs = inputs: inputs.glue { inherit inputs; };
}

14
glue/flake.nix Normal file
View File

@ -0,0 +1,14 @@
{
description = "Some glue";
inputs = { };
outputs =
inputs:
let
glue = import ./lib { inherit inputs; };
in
{
__functor = _: glue;
};
}

167
glue/lib/default.nix Normal file
View File

@ -0,0 +1,167 @@
{ ... }:
let
mkGlue =
{
inputs,
...
}:
let
flake = inputs.self;
nixpkgs = inputs.nixpkgs;
lib = nixpkgs.lib;
importDir =
path: fn:
let
entries = builtins.readDir path;
# Get paths to directories
dirs = lib.filterAttrs (_: type: type == "directory") entries;
dirPaths = lib.mapAttrs (name: type: {
path = "${path}/${name}";
type = type;
}) dirs;
# Get paths to nix files
nixName = name: builtins.match "(.*)\\.nix" name;
files = lib.filterAttrs (name: type: (type != "directory") && ((nixName name) != null)) entries;
filePaths = lib.mapAttrs' (name: type: {
name = builtins.head (nixName name);
value = {
path = "${path}/${name}";
type = type;
};
}) files;
combined = dirPaths // filePaths;
in
fn (lib.optionalAttrs (builtins.pathExists path) combined);
# Split out into getNixFiles, getNixFilesRecursive, getDirs
importDirRecursive =
path: fn:
let
entries = importDir path lib.id;
# Dig down recursively
dirs = lib.filterAttrs (_: entry: entry.type == "directory") entries;
recursedEntries = lib.mapAttrs (name: entry: (importDirRecursive entry.path lib.id)) dirs;
in
fn (entries // recursedEntries);
systems = [
"x86_64-linux"
"aarch64-linux"
];
eachSystem = fn: lib.genAttrs systems fn;
systemArgs = eachSystem (system: {
pkgs = (
import inputs.nixpkgs {
inherit system;
}
);
});
allPackages = importDir "${flake}/packages" (
attrs:
lib.mapAttrs (
name: entry: (if entry.type == "directory" then "${entry.path}/default.nix" else entry.path)
) attrs
);
packages =
let
# TODO: Filter out packages that are not supported on the platform?
mkPackages =
system:
let
args = systemArgs."${system}";
pkgs = args.pkgs;
in
lib.mapAttrs (name: package: pkgs.callPackage package { }) allPackages;
in
eachSystem mkPackages;
overlay = final: prev: (lib.mapAttrs (name: package: prev.callPackage package { }) allPackages);
collectEntries =
attrs:
lib.attrsets.collect (
entry: (lib.isAttrs entry) && (lib.hasAttr "path" entry) && (lib.hasAttr "type" entry)
) attrs;
collectModules =
path:
importDirRecursive path (
attrs:
map (entry: if entry.type == "directory" then entry.path + "/default.nix" else entry.path) (
collectEntries attrs
)
);
nixosModules = collectModules "${flake}/modules/nixos";
homeModules = collectModules "${flake}/modules/home";
overlayModule =
{ ... }:
{
nixpkgs.overlays = [ overlay ];
};
homeManager = inputs.home-manager.nixosModules.home-manager;
nixosConfigurations = importDir "${flake}/hosts" (
attrs:
lib.mapAttrs (
name: entry:
lib.nixosSystem {
specialArgs = {
inherit inputs;
};
modules =
let
systemPath = "${entry.path}/configuration.nix";
userEntries = importDir "${entry.path}/users" lib.id;
usersConfiguration = lib.mapAttrs (name: entry: {
isNormalUser = true;
group = name;
}) userEntries;
groupsConfiguration = lib.mapAttrs (name: entry: {
}) userEntries;
homesConfiguration = lib.mapAttrs (name: entry: entry.path) userEntries;
usersModule =
{ ... }:
{
home-manager.sharedModules = homeModules;
home-manager.useUserPackages = false; # TODO: See if this should be changed to true?
home-manager.useGlobalPkgs = true;
home-manager.users = homesConfiguration;
users.users = usersConfiguration;
users.groups = groupsConfiguration;
};
in
[
systemPath
overlayModule
usersModule
homeManager
]
++ nixosModules;
}
) (lib.attrsets.filterAttrs (name: entry: entry.type == "directory") attrs)
);
in
{
inherit packages nixosConfigurations;
overlays.default = overlay;
};
in
mkGlue

View File

@ -0,0 +1,20 @@
{ flake, ... }:
{
# State version
system.stateVersion = "24.05";
# Machine hostname
networking.hostName = "20212060";
# Admin users
users.users.jan.extraGroups = [ "wheel" ];
modules = {
profiles.laptop.enable = true;
};
imports = [
./hardware-configuration.nix
];
}

View File

@ -0,0 +1,43 @@
{ ... }:
{
# Machine platform
nixpkgs.hostPlatform = "x86_64-linux";
# Hardware configuration
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [
"xhci_pci"
"nvme"
"usb_storage"
"sd_mod"
"rtsx_pci_sdmmc"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
hardware.cpu.intel.updateMicrocode = true;
# Filesystems
fileSystems."/" = {
device = "/dev/disk/by-uuid/3b91eaeb-ea95-4bea-8dc1-f55af7502d23";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/46BF-DE2C";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
# Swapfile
swapDevices = [
{
device = "/var/lib/swapfile";
size = 16 * 1024;
}
];
}

View File

@ -0,0 +1,99 @@
{
pkgs,
...
}:
{
home.stateVersion = "24.11";
home.packages = with pkgs; [
libreoffice-still
remmina
thunderbird
signal-desktop
prusa-slicer
freecad-wayland
inkscape
ente-auth
bitwarden
carla
baobab
gnome-calculator
nautilus
winbox
whatsapp-for-linux
discord
steam
spotify
# feishin # TODO: Fix or replace as insecure
eduvpn-client
river # TODO: Move
firefox # TODO: Move to dediated module
ryubing
];
modules = {
# Desktop environment
desktop.gnome.enable = true;
# desktop.tiling.enable = true;
# Browser
# firefox = {
# enable = true;
# default = false;
# };
# qutebrowser = {
# enable = true;
# default = true;
# };
# Gaming
# retroarch.enable = true;
# ryujinx.enable = true;
# Tools
git = {
enable = true;
user = "Jan-Bulthuis";
email = "git@bulthuis.dev";
# TODO: Move
ignores = [
".envrc"
".direnv"
"flake.nix"
"flake.lock"
];
};
# btop.enable = true;
direnv.enable = true;
fish.enable = true;
# bluetuith.enable = false;
# obsidian.enable = true;
# zathura.enable = true;
# keyring.enable = true;
# scripts.enable = true;
xpra = {
enable = true;
hosts = [
"mixer@10.20.60.251"
];
};
# Development
# neovim.enable = true;
vscode.enable = true;
# docker.enable = true;
# matlab.enable = true;
# mathematica.enable = true;
# Languages
haskell.enable = false;
js.enable = false;
nix.enable = true;
rust.enable = true;
python.enable = true;
cpp.enable = true;
tex.enable = true;
jupyter.enable = false;
};
}

View File

@ -0,0 +1,17 @@
{
pkgs,
...
}:
{
home.stateVersion = "24.11";
home.packages = with pkgs; [
];
modules = {
# Desktop environment
# desktop.gnome.enable = true;
# desktop.tiling.enable = true;
};
}

View File

@ -0,0 +1,32 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.desktop.gnome;
in
{
options.modules.desktop.gnome = {
enable = mkEnableOption "gnome";
};
config = mkIf cfg.enable {
# TODO: Enable extensions with dconf
home.packages =
with pkgs;
[
gnome-control-center
gnome-tweaks
blackbox-terminal
]
++ (with pkgs.gnomeExtensions; [
gsconnect
disable-workspace-animation
]);
};
}

View File

@ -0,0 +1,20 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.desktop.tiling;
in
{
options.modules.desktop.tiling = {
enable = mkEnableOption "tiling desktop";
};
config = mkIf cfg.enable {
};
}

View File

@ -0,0 +1,53 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.git;
in
{
options.modules.git = {
enable = mkEnableOption "git";
user = mkOption {
type = types.str;
description = "Default user name to use.";
};
email = mkOption {
type = types.str;
description = "Default user email to use.";
};
ignores = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Paths to globally ignore";
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
git
lazygit
];
programs.git = {
enable = true;
extraConfig = {
pull = {
rebase = false;
};
};
userName = cfg.user;
userEmail = cfg.email;
ignores = cfg.ignores;
};
};
}

View File

@ -0,0 +1,50 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.cpp;
in
{
options.modules.cpp = {
enable = mkEnableOption "cpp";
};
config = mkIf cfg.enable {
# Gitignore additions
modules.git.ignores = [
".ccls-cache"
];
# Development packages
home.packages = with pkgs; [
gnumake
gcc
];
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [
ms-vscode.cpptools
ms-vscode.cmake-tools
ms-vscode.cpptools-extension-pack
];
userSettings = {
# TODO: Add setting to set the compiler, it currently needs to be set for each workspace individually
# "C_Cpp.clang_format_fallbackStyle" = "{ BasedOnStyle: Google, IndentWidth: 4 }";
};
};
};
# Neovim configuration
# programs.nixvim = {
# plugins.lsp.servers.ccls.enable = true;
# };
};
}

View File

@ -0,0 +1,42 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.haskell;
in
{
options.modules.haskell = {
enable = mkEnableOption "haskell";
};
config = mkIf cfg.enable {
# Development packages
home.packages = with pkgs; [
haskell.compiler.ghc948
(haskell-language-server.override { supportedGhcVersions = [ "948" ]; })
];
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [
haskell.haskell
justusadam.language-haskell
];
userSettings = {
"[haskell]" = { };
# "haskell.formattingProvider" = "fourmolu";
};
};
};
# Neovim configuration
# programs.nixvim = { };
};
}

View File

@ -0,0 +1,38 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.js;
in
{
options.modules.js = {
enable = mkEnableOption "js";
};
config = mkIf cfg.enable {
# Development packages
home.packages = with pkgs; [
nodejs
tailwindcss
];
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [
bradlc.vscode-tailwindcss
];
userSettings = { };
};
};
# Neovim configuration
# programs.nixvim = { };
};
}

View File

@ -0,0 +1,44 @@
{
lib,
config,
pkgs,
...
}:
# TODO: Move to a module for notebooks in general
with lib;
let
cfg = config.modules.jupyter;
in
{
options.modules.jupyter = {
enable = mkEnableOption "jupyter";
};
config = mkIf cfg.enable {
# Development packages
# home.packages = with pkgs; [
# evcxr
# ];
# modules.python.extraPythonPackages = p: [
# p.jupyter
# p.notebook
# ];
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [
ms-toolsai.jupyter
ms-toolsai.jupyter-renderers
];
userSettings = { };
};
};
# Neovim configuration
# programs.nixvim = { };
};
}

View File

@ -0,0 +1,60 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.nix;
in
{
options.modules.nix = {
enable = mkEnableOption "nix";
};
config = mkIf cfg.enable {
# Development packages
home.packages = with pkgs; [
nix-tree
nixfmt-rfc-style
nixd
];
# Add nix tree
xdg.desktopEntries.nix-tree = {
exec = "${pkgs.nix-tree}/bin/nix-tree";
name = "Nix Tree";
terminal = true;
type = "Application";
};
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [ jnoortheen.nix-ide ];
userSettings = {
"[nix]" = {
"editor.tabSize" = 2;
};
"nix.enableLanguageServer" = true;
"nix.serverPath" = "nixd";
"nix.serverSettings" = {
nixd = {
formatting = {
command = [ "nixfmt" ];
};
};
};
};
};
};
# Neovim configuration
# programs.nixvim = {
# };
};
}

View File

@ -0,0 +1,52 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.python;
in
{
options.modules.python = {
enable = mkEnableOption "python";
extraPythonPackages = mkOption {
type = types.functionTo (types.listOf types.package) // {
merge =
loc: defs: p:
lib.concatMap (def: (def.value p)) defs;
};
default = p: [ ];
description = "Extra Python packages to install";
};
};
config = mkIf cfg.enable {
# Development packages
home.packages = [ ];
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [
ms-python.python
ms-python.debugpy
ms-python.vscode-pylance
ms-python.black-formatter
];
userSettings = {
"python.defaultInterpreterPath" = "\${env:PYTHONINTERPRETER}";
"[python]" = {
"editor.defaultFormatter" = "ms-python.black-formatter";
};
};
};
};
# Neovim configuration
# programs.nixvim = { };
};
}

View File

@ -0,0 +1,59 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.rust;
in
{
options.modules.rust = {
enable = mkEnableOption "rust";
};
config = mkIf cfg.enable {
# Development packages
home.packages = with pkgs; [
# rustup
# rustc
# cargo
# gcc
# lldb
# bacon
# rust-analyzer
# rustfmt
# clippy
# evcxr
];
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [
rust-lang.rust-analyzer
vadimcn.vscode-lldb
tamasfe.even-better-toml
serayuzgur.crates
];
userSettings = {
"[rust]" = {
"editor.inlayHints.enabled" = "off";
};
"rust-analyzer.check.command" = "clippy";
"rust-analyzer.showUnlinkedFileNotification" = false;
};
};
};
# Neovim configuration
# programs.nixvim = {
# plugins.rustaceanvim = {
# enable = true;
# };
# };
};
}

View File

@ -0,0 +1,69 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.tex;
in
{
options.modules.tex = {
enable = mkEnableOption "tex";
};
config = mkIf cfg.enable {
# Development packages
home.packages = with pkgs; [
(texlive.combine {
inherit (texlive) scheme-full;
})
];
# Pygments for minted
modules.python.extraPythonPackages = p: [
p.pygments
];
# VSCode configuration
programs.vscode = {
profiles.default = {
extensions = with pkgs.vscode-extensions; [ jnoortheen.nix-ide ];
userSettings = {
"[tex]" = { };
};
};
};
# Neovim configuration
# programs.nixvim = {
# extraConfigVim = ''
# " Enforce latexmk
# let g:vimtex_compiler_method = 'latexmk'
# " Set latexmk compilation settings
# let g:vimtex_compiler_latexmk = {
# \ 'options': [
# \ '-shell-escape',
# \ '-verbose',
# \ '-file-line-error',
# \ '-synctex=1',
# \ '-interaction=nonstopmode',
# \ ],
# \}
# '';
# # Vimtex plugin
# plugins.vimtex = {
# enable = true;
# texlivePackage = null;
# settings = {
# view_method = "zathura";
# };
# };
# };
};
}

View File

@ -0,0 +1,27 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.mathematica;
my-mathematica = pkgs.mathematica.override {
# TODO: Just use a generic name for the installer?
# source = ./Wolfram_14.2.1_LIN_Bndl.sh;
};
in
{
options.modules.mathematica = {
enable = mkEnableOption "mathematica";
};
config = mkIf cfg.enable {
home.packages = [
my-mathematica
];
};
}

View File

@ -0,0 +1,190 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.neovim;
# theme = config.desktop.theming;
# colors = theme.colors;
in
{
options.modules.neovim = {
enable = mkEnableOption "neovim";
};
config = mkIf cfg.enable {
# programs.nixvim = {
# enable = true;
# defaultEditor = true;
# viAlias = true;
# vimAlias = true;
# # extraPackages = with pkgs; [ ];
# opts = {
# number = true;
# relativenumber = true;
# signcolumn = "yes";
# ignorecase = true;
# smartcase = true;
# tabstop = 4;
# shiftwidth = 4;
# softtabstop = 0;
# expandtab = true;
# smarttab = true;
# list = true;
# listchars = "tab:»┈«,trail:·,extends:→,precedes:←,nbsp:␣";
# };
# diagnostic.settings = {
# enable = true;
# signs = true;
# underline = true;
# update_in_insert = true;
# };
# extraConfigLua = ''
# vim.fn.sign_define("DiagnosticSignError",
# {text = "", texthl = "DiagnosticSignError"})
# vim.fn.sign_define("DiagnosticSignWarn",
# {text = "", texthl = "DiagnosticSignWarn"})
# vim.fn.sign_define("DiagnosticSignInfo",
# {text = "", texthl = "DiagnosticSignInfo"})
# vim.fn.sign_define("DiagnosticSignHint",
# {text = "💡", texthl = "DiagnosticSignHint"})
# '';
# keymaps = [
# # Save shortcut
# {
# action = ":update<CR>";
# key = "<C-s>";
# mode = "n";
# }
# {
# action = "<C-o>:update<CR>";
# key = "<C-s>";
# mode = "i";
# }
# # Neo tree
# {
# action = ":Neotree action=focus reveal toggle<CR>";
# key = "<leader>n";
# mode = "n";
# options.silent = true;
# }
# ];
# autoCmd = [
# {
# desc = "Automatic formatting";
# event = "BufWritePre";
# callback = {
# __raw = ''
# function()
# vim.lsp.buf.format {
# async = false,
# }
# end
# '';
# };
# }
# ];
# # highlight = {
# # Comment = {
# # italic = true;
# # fg = theme.schemeColors.withHashtag.base03; # TODO: Come up with a good name colors.muted maybe?
# # };
# # };
# plugins.lsp = {
# enable = true;
# };
# #plugins.treesitter = {
# # enable = true;
# #};
# plugins.cmp = {
# enable = true;
# settings = {
# mapping = {
# "<C-Space>" = "cmp.mapping.complete()";
# "<C-d>" = "cmp.mapping.scroll_docs(-4)";
# "<C-e>" = "cmp.mapping.close()";
# "<C-f>" = "cmp.mapping.scroll_docs(4)";
# "<CR>" = "cmp.mapping.confirm({ select = true })";
# "<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
# "<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
# };
# sources = [
# { name = "path"; }
# { name = "nvim_lsp"; }
# ];
# };
# };
# plugins.web-devicons = {
# enable = true;
# };
# plugins.neo-tree = {
# enable = true;
# closeIfLastWindow = true;
# window = {
# width = 30;
# autoExpandWidth = true;
# };
# extraOptions = {
# default_component_configs.git_status.symbols = {
# # Change type
# added = "+";
# deleted = "✕";
# modified = "✦";
# renamed = "→";
# # Status type
# untracked = "?";
# ignored = "▫";
# unstaged = "□";
# staged = "■";
# conflict = "‼";
# };
# };
# };
# #plugins.cmp-nvim-lsp.enable = true;
# plugins.gitsigns = {
# enable = true;
# settings.current_line_blame = true;
# };
# #plugins.copilot-vim = {
# # enable = true;
# #};
# # plugins.vimtex = {
# # enable = true;
# # texlivePackage = null;
# # settings = {
# # view_method = "zathura";
# # };
# # };
# };
# programs.neovim.defaultEditor = true;
};
}

View File

@ -0,0 +1,96 @@
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.vscode;
# theme = config.desktop.theming;
in
{
options.modules.vscode = {
enable = mkEnableOption "vscode";
# codeFont = mkOption {
# type = types.anything;
# default = theme.fonts.pkgs."Fira Code";
# };
# fallbackFont = mkOption {
# type = types.anything;
# default = theme.fonts.pkgs."Symbols Nerd Font Mono";
# };
};
config = mkIf cfg.enable {
# TODO: Fix theming
# desktop.theming.fonts.extraFonts = [ cfg.codeFont ];
programs.vscode = {
enable = true;
mutableExtensionsDir = false;
profiles.default = {
extensions = with pkgs.vscode-extensions; [
eamodio.gitlens
ms-vscode.hexeditor
mkhl.direnv
usernamehw.errorlens
gruntfuggly.todo-tree
github.copilot
github.copilot-chat
tomoki1207.pdf
ms-vsliveshare.vsliveshare
ms-vscode-remote.remote-ssh
];
userSettings =
let
# font-family = mkForce "'${cfg.codeFont.name}', '${cfg.fallbackFont.name}'";
# TODO: Move the conversion factor to theme settings
# font-size = mkForce cfg.codeFont.recommendedSize; # Convert pt to px
in
{
# Font setup
# "editor.fontFamily" = font-family;
# "editor.inlayHints.fontFamily" = font-family;
# "editor.inlineSuggest.fontFamily" = font-family;
# "editor.fontSize" = font-size;
# "editor.fontLigatures" = true;
# "terminal.integrated.fontFamily" = font-family;
# "terminal.integrated.fontSize" = font-size;
# "chat.editor.fontFamily" = font-family; # TODO: Change this font to the standard UI font
# "chat.editor.fontSize" = font-size;
# "debug.console.fontFamily" = font-family;
# "debug.console.fontSize" = font-size;
# "scm.inputFontFamily" = font-family; # TODO: Change this font to the standard UI font
# "scm.inputFontSize" = font-size;
# "markdown.preview.fontFamily" = mkForce theme.fonts.sansSerif.name; # TODO: Change this font to the standard UI font
# "markdown.preview.fontSize" = mkForce theme.fonts.sansSerif.recommendedSize;
# Formatting
"editor.formatOnSave" = true;
"editor.tabSize" = 4;
# Layout
"window.menuBarVisibility" = "hidden";
# Git settings
"git.autofetch" = true;
"git.enableSmartCommit" = false;
"git.suggestSmartCommit" = false;
# Disable update notifications
"update.mode" = "none";
# TODO: Move to direnv module
# Ignore direnv folder
"files.exclude" = {
".direnv" = true;
};
};
};
};
};
}

View File

@ -0,0 +1,27 @@
{
lib,
config,
...
}:
with lib;
let
cfg = config.modules.bash;
in
{
options.modules.bash = {
enable = mkEnableOption "bash";
aliases = mkOption {
type = types.attrsOf types.str;
default = {
"..." = "cd ../..";
};
description = "Shell aliases";
};
};
config.programs.bash = {
enable = cfg.enable;
shellAliases = cfg.aliases;
};
}

View File

@ -0,0 +1,26 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.direnv;
in
{
options.modules.direnv = {
enable = mkEnableOption "direnv";
};
config = mkIf cfg.enable {
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
modules.git.ignores = [
".direnv"
];
};
}

View File

@ -0,0 +1,57 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.fish;
in
{
options.modules.fish = {
enable = mkEnableOption "fish";
};
config = mkIf cfg.enable {
# Make bash load into fish
# Bash will remain the default shell as fish is not POSIX compliant.
modules.bash.enable = true;
programs.bash.initExtra = ''
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
fi
'';
# Actual fish configuration
programs.fish = {
enable = true;
shellAliases = config.modules.bash.aliases;
plugins = [
{
name = "done";
src = pkgs.fishPlugins.done.src;
}
{
name = "fzf";
src = pkgs.fishPlugins.fzf-fish.src;
}
{
name = "grc";
src = pkgs.fishPlugins.grc.src;
}
];
};
# Fish plugin dependencies
home.packages = with pkgs; [
fzf
grc
];
};
}

View File

@ -0,0 +1,63 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.xpra;
in
{
options.modules.xpra = {
enable = mkEnableOption "Enable xpra";
hosts = mkOption {
type = types.listOf types.str;
default = { };
description = "xpra hosts";
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
xpra
];
xdg.desktopEntries = (
listToAttrs (
map
(entry: {
name = "xpra${
builtins.substring 0 12 (builtins.hashString "sha256" "${entry.name} (${entry.comment})")
}";
value = entry // {
type = "Application";
terminal = false;
genericName = entry.comment;
};
})
(
concatMap (
host:
let
uri = "tcp://${host}:15151/7";
in
[
{
name = "Xpra - Attach";
comment = host;
exec = "xpra attach --min-quality=100 --min-speed=100 --encoding=png --speaker=off ${uri}";
}
{
name = "Xpra - Detach";
comment = host;
exec = "xpra detach ${uri}";
}
]
) cfg.hosts
)
)
);
};
}

View File

@ -0,0 +1,18 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.bluetooth;
in
{
options.modules.bluetooth = {
enable = mkEnableOption "bluetooth";
};
config = mkIf cfg.enable {
# Enable bluetooth
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
};
};
}

View File

@ -0,0 +1,20 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.bootloader;
in
{
options.modules.bootloader = {
enable = mkEnableOption "bootloader";
};
config = mkIf cfg.enable {
# Bootloader
boot.loader = {
timeout = 0;
systemd-boot.enable = true;
systemd-boot.editor = false;
efi.canTouchEfiVariables = true;
};
};
}

35
modules/nixos/fonts.nix Normal file
View File

@ -0,0 +1,35 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.fonts;
in
{
options.modules.fonts = {
enable = mkEnableOption "fonts";
};
config = mkIf cfg.enable {
console.packages = [
pkgs.dina-psfu
];
console.font = "dina";
console.earlySetup = true;
# TODO: Disable default fonts, fonts should be managed per user
# fonts.enableDefaultPackages = false;
# fonts.fontconfig = {
# enable = true;
# defaultFonts = {
# serif = mkDefault [ ];
# sansSerif = mkDefault [ ];
# monospace = mkDefault [ ];
# emoji = mkDefault [ ];
# };
# };
};
}

95
modules/nixos/gnome.nix Normal file
View File

@ -0,0 +1,95 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
cfg = config.modules.gnome;
in
{
options.modules.gnome = {
enable = mkEnableOption "gnome";
# TODO: Add RDP toggle
};
config = mkIf cfg.enable {
# Enable GDM and Gnome
services.xserver.enable = true;
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
services.gnome.core-utilities.enable = false;
services.gnome.games.enable = false;
services.gnome.core-developer-tools.enable = false;
environment.gnome.excludePackages = with pkgs; [
adwaita-icon-theme
(derivation { name = "nixos-background-info"; })
gnome-backgrounds
gnome-bluetooth
gnome-color-manager
gnome-control-center
gnome-shell-extensions
gnome-tour
gnome-user-docs
glib
gnome-menus
gtk3.out
xdg-user-dirs
xdg-user-dirs-gtk
];
# Set up desktop entries for possible desktop environments
services.displayManager.sessionPackages = [
(pkgs.writeTextFile {
name = "river.desktop";
text = ''
[Desktop Entry]
Name=River
Comment=A dynamic tiling Wayland compositor
Exec=river
Type=Application
'';
destination = "/share/wayland-sessions/river.desktop";
passthru.providedSessions = [ "river" ];
})
];
# Enable Gnome Remote Desktop
services.gnome.gnome-remote-desktop.enable = true;
systemd.services."gnome-remote-desktop".wantedBy = [ "graphical.target" ];
networking.firewall = {
allowedTCPPorts = [
3389
3390
];
allowedUDPPorts = [
3389
3390
];
};
# For GSConnect/KDE Connect
# TODO: Move to host config?
networking.firewall = {
allowedTCPPortRanges = [
{
from = 1714;
to = 1764;
}
];
allowedUDPPortRanges = [
{
from = 1714;
to = 1764;
}
];
};
# Enable dependencies
modules = {
networkmanager.enable = true;
};
};
}

View File

@ -0,0 +1,22 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.graphics;
in
{
options.modules.graphics = {
enable = mkEnableOption "graphics";
# TODO: Add toggle for hybrid graphics
};
config = mkIf cfg.enable {
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
services.xserver.videoDrivers = [ "nvidia" ];
# TODO: Add nvidia settings back in
# TODO: Move to nvidia module
hardware.nvidia = {
open = true;
};
};
}

View File

@ -0,0 +1,15 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.networkmanager;
in
{
options.modules.networkmanager = {
enable = mkEnableOption "networkmanager";
};
config = mkIf cfg.enable {
# TODO: Add sudo users to the networkmanager group?
networking.networkmanager.enable = true;
};
}

View File

@ -0,0 +1,20 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.power-saving;
in
{
options.modules.power-saving = {
enable = mkEnableOption "power saving";
};
config = mkIf cfg.enable {
# Setup power management
powerManagement.enable = true;
services.thermald.enable = true;
services.power-profiles-daemon.enable = true;
# Enable wifi power saving
networking.networkmanager.wifi.powersave = true;
};
}

View File

@ -0,0 +1,22 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.printing;
in
{
options.modules.printing = {
enable = mkEnableOption "printing";
};
config = mkIf cfg.enable {
# Enable CUPS
services.printing.enable = true;
# Enable Avahi to auto-detect network printers
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
};
}

View File

@ -0,0 +1,61 @@
{
mkModule,
pkgs,
lib,
config,
...
}:
with lib;
let
cfg = config.modules.profiles.base;
in
{
options.modules.profiles.base = {
enable = mkEnableOption "base profile";
};
config = mkIf cfg.enable {
modules = {
bootloader.enable = mkDefault true;
ssh.enable = mkDefault true;
};
# Localization
time.timeZone = "Europe/Amsterdam";
i18n.defaultLocale = "en_US.UTF-8";
console.keyMap = "us";
# Enable neovim
programs.neovim = {
enable = true;
defaultEditor = true;
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Enable the usage of flakes
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
# Clean tmp
boot.tmp.cleanOnBoot = true;
# Base packages
environment.systemPackages = with pkgs; [
git
wget
curl
dig
procps
wireguard-tools
usbutils
pciutils
zip
unzip
];
};
}

View File

@ -0,0 +1,28 @@
{
pkgs,
lib,
config,
...
}:
with lib;
let
cfg = config.modules.profiles.desktop;
in
{
options.modules.profiles.desktop = {
enable = mkEnableOption "desktop profile";
};
config = mkIf cfg.enable {
modules = {
profiles.base.enable = mkDefault true;
fonts.enable = mkDefault true;
graphics.enable = mkDefault true;
gnome.enable = mkDefault true; # TODO: Rename to display manager?
networkmanager.enable = mkDefault true;
printing.enable = mkDefault true;
sound.enable = mkDefault true;
};
};
}

View File

@ -0,0 +1,30 @@
{
pkgs,
lib,
config,
...
}:
with lib;
let
cfg = config.modules.profiles.laptop;
in
{
options.modules.profiles.laptop = {
enable = mkEnableOption "laptop profile";
};
config = mkIf cfg.enable {
# Setup modules
modules = {
profiles.desktop.enable = mkDefault true;
bluetooth.enable = mkDefault true;
power-saving.enable = mkDefault true;
};
# Add packages
environment.systemPackages = with pkgs; [
brightnessctl
];
};
}

24
modules/nixos/sound.nix Normal file
View File

@ -0,0 +1,24 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.sound;
in
{
options.modules.sound = {
enable = mkEnableOption "sound";
};
config = mkIf cfg.enable {
# Enable pipewire
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
# Recommended by wiki, allows user processes to use realtime kernel
security.rtkit.enable = true;
};
}

15
modules/nixos/ssh.nix Normal file
View File

@ -0,0 +1,15 @@
{ lib, config, ... }:
with lib;
let
cfg = config.modules.ssh;
in
{
options.modules.ssh = {
enable = mkEnableOption "ssh";
};
config = mkIf cfg.enable {
services.openssh.enable = true;
# TODO: Is this default configuration secure?
};
}

View File

@ -1,63 +0,0 @@
{ lib, ... }:
{
imports = [
# Import environment
../default.nix
];
config = {
# State version
system.stateVersion = "24.05";
# Machine hostname
networking.hostName = "20212060";
# Enabled modules
modules = {
base.desktop.enable = true;
bluetooth.enable = true;
power-saving.enable = false;
networkmanager.enable = true;
grdp.enable = true;
printing.enable = true;
};
# Hardware configuration
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [
"xhci_pci"
"nvme"
"usb_storage"
"sd_mod"
"rtsx_pci_sdmmc"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
hardware.cpu.intel.updateMicrocode = true;
# Filesystems
fileSystems."/" = {
device = "/dev/disk/by-uuid/3b91eaeb-ea95-4bea-8dc1-f55af7502d23";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/46BF-DE2C";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
# Swapfile
swapDevices = [
{
device = "/var/lib/swapfile";
size = 16 * 1024;
}
];
};
}

370
unorganized/users/jan.nix Normal file
View File

@ -0,0 +1,370 @@
{
lib,
config,
pkgs,
...
}:
{
config = (
lib.recursiveUpdate
{
# State version
home.stateVersion = "24.05";
# TODO: Move into modules
home.packages = with pkgs; [
libreoffice-still
remmina
pinentry
thunderbird
signal-desktop
prusa-slicer
freecad-wayland
inkscape
ente-auth
bitwarden
carla
baobab
gnome-calculator
nautilus
];
# desktop.development = "river-light";
desktop.enable = true;
desktop.environments = {
river-dark = {
name = "River Dark";
type = "custom";
config = { };
extraConfig = {
modules = {
# Desktop environment
river.enable = true;
waylock.enable = true;
waybar.enable = true;
mako.enable = true;
foot.enable = true;
rofi-rbw.enable = true;
};
# TODO: Remove everything below, it is here out of convenience and should be elsewhere
xdg.portal = {
enable = true;
config.common.default = [
"wlr"
"gtk"
];
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-wlr
];
};
# Color scheme
desktop.theming.background = {
image = {
url = "https://i.postimg.cc/tTB3dM3T/1382899.png";
hash = "sha256-kStcwAtK2vxitU6uaQtZTA5iFS8k0iXkFwinY2M8wQE=";
};
themed = true;
inverted = false;
};
desktop.theming.themes.catppuccin = {
enable = true;
flavor = "mocha";
};
};
};
river-light = {
name = "River Light";
type = "custom";
config = { };
extraConfig = {
modules = {
# Desktop environment
river.enable = true;
waylock.enable = true;
waybar.enable = true;
mako.enable = true;
foot.enable = true;
rofi-rbw.enable = true;
};
# TODO: Remove everything below, it is here out of convenience and should be elsewhere
xdg.portal = {
enable = true;
config.common.default = [
"wlr"
"gtk"
];
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-wlr
];
};
# Color scheme
desktop.theming.background = {
image = {
url = "https://raw.githubusercontent.com/dharmx/walls/refs/heads/main/digital/a_drawing_of_a_spider_on_a_white_surface.png";
hash = "sha256-eCEjM7R9yeHNhZZtvHjrgkfwT25JA7FeMoVwnQ887CQ=";
};
themed = true;
inverted = false;
};
desktop.theming.themes.catppuccin = {
enable = true;
flavor = lib.mkForce "latte";
};
};
};
gnome = {
name = "Gnome";
type = "custom";
config = { };
extraConfig = {
programs = {
gnome-shell.enable = true;
};
desktop = {
initScript = ''
${pkgs.gnome-session}/bin/gnome-session
'';
session = {
type = "wayland";
desktop = "GNOME";
};
};
modules.river.enable = lib.mkForce false;
# TODO: Remove everything below, it is here out of convenience and should be elsewhere
xdg.portal = {
enable = true;
config.common.default = [
"gnome"
"gtk"
];
extraPortals = with pkgs; [
xdg-desktop-portal-gnome
xdg-desktop-portal-gtk
];
};
home.packages = [
# Core utilities
pkgs.epiphany
pkgs.gnome-text-editor
pkgs.gnome-calendar
pkgs.gnome-characters
pkgs.gnome-clocks
pkgs.gnome-console
pkgs.gnome-contacts
pkgs.gnome-font-viewer
pkgs.gnome-logs
pkgs.gnome-maps
pkgs.gnome-music
pkgs.gnome-system-monitor
pkgs.gnome-weather
pkgs.loupe
pkgs.gnome-connections
pkgs.simple-scan
pkgs.snapshot
pkgs.totem
pkgs.yelp
# Optional packages
pkgs.adwaita-icon-theme
pkgs.gnome-backgrounds
pkgs.gnome-bluetooth
pkgs.gnome-color-manager
pkgs.gnome-control-center
pkgs.gnome-shell-extensions
pkgs.gnome-tour # GNOME Shell detects the .desktop file on first log-in.
pkgs.gnome-user-docs
pkgs.glib # for gsettings program
pkgs.gnome-menus
pkgs.gtk3.out # for gtk-launch program
pkgs.xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
pkgs.xdg-user-dirs-gtk # Used to create the default bookmarks
# Fonts
pkgs.cantarell-fonts
pkgs.dejavu_fonts
pkgs.source-code-pro # Default monospace font in 3.32
pkgs.source-sans
# Other stuff
pkgs.gnome-session
];
};
};
};
# Pipewire roc sink
xdg.configFile."pipewire/pipewire.conf.d/60-roc-sink.conf" = {
text = ''
context.modules = [
{
name = "libpipewire-module-roc-sink"
args = {
fec.code = "rs8m"
remote.ip = "10.20.60.251"
remote.source.port = 10001
remote.repair.port = 10002
sink.name = "Roc Sink"
sink.props.node.name = "roc-sink"
}
}
]
'';
};
# Enabled modules
modules = {
# Communication
whatsapp.enable = true;
discord.enable = true;
# Browser
firefox = {
enable = true;
default = false;
};
qutebrowser = {
enable = true;
default = true;
};
# Gaming
steam.enable = true;
# modrinth.enable = true;
# es-de.enable = true; # TODO: Fix, again
retroarch.enable = true;
ryujinx.enable = true;
# Media
spotify.enable = true;
feishin.enable = true;
# Tools
git = {
enable = true;
user = "Jan-Bulthuis";
email = "git@bulthuis.dev";
# TODO: Move
ignores = [
".envrc"
".direnv"
"flake.nix"
"flake.lock"
];
};
btop.enable = true;
fish.enable = true;
bluetuith.enable = false;
winbox.enable = true;
obsidian.enable = true;
zathura.enable = true;
eduvpn.enable = true;
keyring.enable = true;
scripts.enable = true;
xpra = {
enable = true;
hosts = [
"mixer@10.20.60.251"
];
};
# Development
neovim.enable = true;
vscode.enable = true;
docker.enable = true;
matlab.enable = true;
mathematica.enable = true;
# Languages
haskell.enable = false;
js.enable = true;
nix.enable = true;
rust.enable = true;
python.enable = true;
cpp.enable = true;
tex.enable = true;
jupyter.enable = true;
# Enable unfree
unfree.enable = true;
};
# Theme configuration
desktop.theming =
let
fontpkgs = config.desktop.theming.fonts.pkgs;
in
lib.mkDefault {
# Fonts
fonts.serif = fontpkgs."DejaVu Serif";
fonts.sansSerif = fontpkgs."DejaVu Sans";
fonts.monospace = fontpkgs."Dina";
fonts.emoji = fontpkgs."Noto Color Emoji";
fonts.interface = fontpkgs."Dina";
fonts.extraFonts = [ ];
# Color scheme
themes.catppuccin = {
enable = true;
flavor = "mocha";
};
};
}
{
# Default desktop environment
modules = {
# Desktop environment
river.enable = true;
waylock.enable = true;
waybar.enable = true;
mako.enable = true;
foot.enable = true;
rofi-rbw.enable = true;
};
# TODO: Remove everything below, it is here out of convenience and should be elsewhere
xdg.portal = {
enable = true;
config.common.default = lib.mkDefault [
"wlr"
"gtk"
];
extraPortals =
with pkgs;
lib.mkDefault [
xdg-desktop-portal-gtk
xdg-desktop-portal-wlr
];
};
# Color scheme
desktop.theming.background = lib.mkDefault {
image = {
url = "https://i.postimg.cc/tTB3dM3T/1382899.png";
hash = "sha256-kStcwAtK2vxitU6uaQtZTA5iFS8k0iXkFwinY2M8wQE=";
};
themed = true;
inverted = false;
};
desktop.theming.themes.catppuccin = {
enable = true;
flavor = "mocha";
};
}
);
}