My NixOS config Part 3: Flake-Parts Crusaders
nix.ladas552.me
hjem
nix
nixos
impermanence
flake-parts
nvfetcher
niri
noctalia
1@document.meta
2title: Nix
3description: Notes on this Nix config
4authors: ladas552
5@end
6
7I start to have a life other than computers so I kinda begin to forget what I did and didn't. So here we are, there will be notes, todos, plans and tips(mostly for myself)
8
9* Notes
10** Scripts
11 I declare scripts with packages that allow to have them in nix format. It allows me to not hold dependencies for certain scripts, like `libnotify` for scripts that send notifications. There are several ways to do this, I prefer bash, but it isn't sufficient in certain places.
12
13 I hold all of my scripts in {./pkgs/}[pkgs] folder
14
15*** writeShellScriptBin
16 The `pkgs.writeShellScriptBin` is used to put a complete bash script into /nix/store with a correct Shebang for it to work. This one is only for `bash` and provides `#!/usr/bin/env bash` shebang
17
18 Example: {./pkgs/word-lookup.nix}[Word look up script written in bash]
19
20*** writers.writeFishBin
21 `pkgs.writers.writeFishBin "musnow.sh" {}` is a way to write scripts in any language, this example is for `fish` shell, but `writers` can be in many forms, from python and lua to rust.
22 The `{}` is set of options can also hold environmental variables.
23
24 Example: {./pkgs/musnow.nix}[To look up comment metadata of mpd track]
25
26** Repository
27
28** Nixos-hardware module
29 Searchable hardware nodules with `nix repl` and command:
30 @code nix
31 (builtins.getFlake ''/home/ladas552/Flake-Ocean'').inputs.nixos-hardware.outputs.nixosModules
32 @end
33
34** Wayland + Electron apps
35 Enable these environmental variables if `NIXOS_OZONE_WL = "1";` doesn't work for you.
36 @code sh
37 ELECTRON_LAUNCH_FLAGS = "--ozone-platform-hint=auto --ozone-platform=wayland --enable-webrtc-pipewire-capturer --enable-features=WaylandWindowDecorations";
38 @end
39
40 And enable these for `fcitx5`
41 @code sh
42 ELECTRON_LAUNCH_FLAGS = "--enable-wayland-ime --wayland-text-input-version=3 --enable-features=WaylandLinuxDrmSyncobj";
43 @end
44
45** xdg.mimeApps
46 Better to declare them in both NixOS options and Home-Manager
47 Example is here
48 @code nix
49 xdg = {
50 enable = true;
51 mime.enable = true;
52 mimeApps = {
53 enable = true;
54 associations.added = {
55 "text/plain" = [ "neovim.desktop" ];
56 "application/pdf" = [ "org.pwmt.zathura-pdf-mupdf.desktop" ];
57 "image/*" = [ "imv.desktop" ];
58 "video/*" = [ "mpv.desktop" ];
59 };
60 defaultApplications = {
61 "text/plain" = [ "" ];
62 "application/pdf" = [ "org.pwmt.zathura-pdf-mupdf.desktop" ];
63 "image/*" = [ "imv.desktop" ];
64 "video/*" = [ "mpv.desktop" ];
65 };
66 };
67 };
68
69 @end
70
71** Sops and secrets
72 Defined in `modules/secrets`, uses the ssh key from my host to decrypt secrets automatically.
73 Can be used as a file, like `${config.sops.secrets."secret"}` and as a string, with `"$(cat ${config.sops.secrets."secret".path})"`
74
75 Change secrets with `sops edit`, creating the keys as per documentation on `sops-nix` repository.
76
77** ZFS
78 I use ZFS as a file system, it provides me with snapshots and compression via zstd. You can't install zfs in calimaries, so need to use nixos iso and configure drive with a {:./docs/zfs.norg:}[script], after that it is simple `nixos-install --flake "github:Ladas552/Nixos-Is-Unbreakable#Host` and setting up a root password at the end
79
80 Zfs is controlled by a {./modules/nixosModules/zfs.nix}[ZFS] module, that also houses my file system config, with a {:./docs/zfs.norg:}[script], they should all be the same, but would need adjustment, namely `/dev/sda` vs `/dev/nvme0n1p` stuff, but thous can be grabbed from Gparted that comes in NixIso
81
82*** To import zpool
83 `sudo zpool import -d /dev/nbd0 -R /mnt zroot`
84** Impermanence
85 I got [Impermanence]{https://github.com/nix-community/impermanence}, and it uses 2 persist mounts. Persist for actual data that is snapshoted, and cache for stuff that I don't wanna redownload or relogin, but not need a back up of. Right now, only `NixPort` has impermanence enabled, and it doesn't bother other NixConfiguration hosts on the setup.
86
87 It's tmpfs setup with zfs datasets.
88** Passwords
89 - root
90 The root password is setup automatically because the users are immutable
91 - user
92 In NixOS, users are Mutual by default, so you can just `su` to change to root, and `passwd ladas552` to change password of user-Ladas552 when you can't login to the user.
93* TODOs
94** Small tasks
95 - (x) Update nextcloud to 32 then 33 on NixToks
96 - ( ) Fix remote builder for NixWool
97 - ( ) Wrap Bash to use the same programs as fish
98
99** Notes
100
101** Programs
102 - *Xremap* or *Keyd*. The button that I have on Acer, binded to Shift+WinL+A. I need to bind ti to PrintScreen
103
104** Modulations
105*** Impermanence
106 Add impermanence for NixToks, but I would need to move all the things from /srv, /var/lib/, /home, and I am toooooooo lazy rn
107
108*** Terminal
109 options for terminals, like what they support for different programs to navigate easely.
110
111 For example,
112 @code nix
113 options.customhm.terminal.name = "kitty";
114 options.customhm.terminal.image = null or sixel or kitty;
115 @end
116 and so on. tho idk how can I pass the home-manager options to my nixos layer, and if I need to tbh
117
118**** update 2025-08-04
119 So, I am switching from foot to ghostty, and really need to get this working sometime. Most of the time, I don't have 2 terminals configured at the same time, so I can just make them options.
120
121 Also I can make work of `optionalString` To add config based exception for niri. Because `journal` keybind doesn't like `''` in foot, but doesn't work with `""` in ghostty
122
123*** Sessions
124 - I want to make wm independent variables for applications. So that I can have For example, 2 configured Launcher applications, but I only want one. Then I just change the variable, and every other module that uses variable `isLauncher` also follows. Basically to have a dozen of WM configs, but if I one day want to switch rofi for dmenu, keybinds would stay the same.
125
126*** Colors
127 I am thinking of swithing to hjem fully one day, but stylix isn't hjem compatable. So I devised an idea. generate files using hjem.files or home.file, in the corresponding config directories. And define the base colorscheme in options. So basically `color16 = ${config.custom.pink}`. And the colors are added with different `import ./colors`, a reference to generated files in, for example kitty config.
128
129 Similar to how Matugen modules works, It generates colors and then you can put them in different files to reference them in your config, it provides runtime based colorscheme solution.
130
131 Nix Colors solution is how you would make colors stateful. Basically every color is defined in options, so it only changes on rebuilds.
132
133 My approach will most similarly look like Nix Colors, while taking the different files approach.
134
135 The only problem I can think of, a lot of manual working involving reading configuration docs. Also some programs may not allow to have imports for colorschemes. So maybe I will just settle with options.