1
0
Fork 0

Compare commits

...

7 commits

Author SHA1 Message Date
Aires c3f4505599 Merge branch 'main' of ssh://code.8bitbuddhism.com/aires/nix-configuration 2024-10-15 20:19:46 -04:00
Aires b5a01ad121 General: update NOS; Users: switch to Starship shell prompt 2024-10-15 12:28:35 -04:00
Aires d1796eedb3 flake.lock: Update
Flake lock file updates:

• Updated input 'nixos-hardware':
    'github:NixOS/nixos-hardware/ecfcd787f373f43307d764762e139a7cdeb9c22b' (2024-10-07)
  → 'github:NixOS/nixos-hardware/a8dd1b21995964b115b1e3ec639dd6ce24ab9806' (2024-10-12)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/d51c28603def282a24fa034bcb007e2bcb5b5dd0' (2024-10-09)
  → 'github:nixos/nixpkgs/a3f9ad65a0bf298ed5847629a57808b97e6e8077' (2024-10-12)
2024-10-13 12:03:13 -04:00
Aires 89d3bc02bf System: cleanup filesystem definition 2024-10-10 14:30:07 -04:00
Aires 1486feaaba General: update default packages 2024-10-10 12:16:37 -04:00
Aires 720feb1ad8 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/1bfbbbe5bbf888d675397c66bfdb275d0b99361c' (2024-10-07)
  → 'github:nixos/nixpkgs/d51c28603def282a24fa034bcb007e2bcb5b5dd0' (2024-10-09)
• Updated input 'nixpkgs-unstable':
    'github:nixos/nixpkgs/c31898adf5a8ed202ce5bea9f347b1c6871f32d1' (2024-10-06)
  → 'github:nixos/nixpkgs/5633bcff0c6162b9e4b5f1264264611e950c8ec7' (2024-10-09)
2024-10-10 09:09:42 -04:00
Aires 0fb1781d79 flake.lock: Update
Flake lock file updates:

• Updated input 'lib':
    'd7762a5a78.tar.gz?dir=lib&narHash=sha256-3MhRNhPikBf/rfqI%2Bz1kprqeyR8OZFgCL6G6ZTFBjR8%3D&rev=d7762a5a78273ffb76da6f6902245983143f63f6' (2024-09-22)
  → '866b8902c9.tar.gz?dir=lib&narHash=sha256-5WHctvz0R9N9oBGda1ROuJ/V/m/tZsEXloGWDrd9G7Y%3D&rev=866b8902c975a1aaec547445976dd39d60def4ab' (2024-10-08)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6' (2024-10-06)
  → 'github:nixos/nixpkgs/1bfbbbe5bbf888d675397c66bfdb275d0b99361c' (2024-10-07)
• Updated input 'nixpkgs-unstable':
    'github:nixos/nixpkgs/bc947f541ae55e999ffdb4013441347d83b00feb' (2024-10-04)
  → 'github:nixos/nixpkgs/c31898adf5a8ed202ce5bea9f347b1c6871f32d1' (2024-10-06)
2024-10-09 10:09:02 -04:00
11 changed files with 126 additions and 1912 deletions

View file

@ -11,47 +11,67 @@ A full set of configuration files managed via NixOS. This project is an **unoffi
Secrets are managed using [git-crypt](https://github.com/AGWA/git-crypt). To unlock the repo, use `git-crypt unlock [path to key file]`. git-crypt will transparently encrypt/decrypt files stored in `modules/secrets` going forward, but you'll need this key file on all hosts that are using secrets. Secrets are managed using [git-crypt](https://github.com/AGWA/git-crypt). To unlock the repo, use `git-crypt unlock [path to key file]`. git-crypt will transparently encrypt/decrypt files stored in `modules/secrets` going forward, but you'll need this key file on all hosts that are using secrets.
Note: This is a poor man's secret management solution. These secrets will be world-readable in the `/nix/store/`. > [!NOTE]
> This is a poor man's secret management solution. If you use this, your secrets will be world-readable in the `/nix/store/`.
### First-time installation ### First-time installation
When installing on a brand new system, partition the main drive into two partitions: a `/boot` partition, and a LUKS partition. Then, run `bin/format-drives.sh --root [root partition] --luks [luks partition]`. This also creates a `hardware-configuration.nix` file. When installing on a brand new system, partition the main drive into two partitions: a `/boot` partition, and a LUKS partition. Then, run `bin/format-drives.sh --root [root partition] --luks [luks partition]` (the script will request sudo privileges):
```sh ```sh
./bin/format-drives.sh --boot /dev/nvme0n1p1 --luks /dev/nvme0n1p2 ./bin/format-drives.sh --boot /dev/nvme0n1p1 --luks /dev/nvme0n1p2
``` ```
Next, set up the host's config under in the `hosts` folder by copying `configuration.nix.template` and `hardware-configuration.nix.template` into a new folder. Next, set up the host's config under in the `hosts` folder by copying `configuration.nix.template` and `hardware-configuration.nix.template` into a new folder. Running `format-drives.sh` also generates a `hardware-configuration.nix` file you can use.
Then, add the host to `flake.nix` under the `nixosConfigurations` section. Then, add the host to `flake.nix` under the `nixosConfigurations` section.
Finally, run the NixOS installer, replacing `host` with your actual hostname: Finally, run the NixOS installer, replacing `host` with your actual hostname:
```sh ```sh
nixos-install --verbose --root /mnt --flake .#host --no-root-password sudo nixos-install --verbose --root /mnt --flake .#host --no-root-password
``` ```
> [!TIP] > [!TIP]
> This config installs a [Nix wrapper called nh](https://github.com/viperML/nh). Basic install/upgrade commands can be run using `nh`, but more advanced stuff should use `nixos-rebuild`. > This config installs a nixos-rebuild wrapper called `nos` (NixOS Operations Script) that handles pulling and pushing changes to your configuration repository via git. For more info, run `nixos-operations-script --help`.
### Running updates ### Running updates
All hosts are configured to run automatic daily updates (see `modules/system/system.nix`). You can disable this by adding `aux.system.services.autoUpgrade = false;` to a host's config. To update a system, run `nixos-operations-script` (or just `nos`). To commit updates back to the repo, use `nos --update`. Do not run this script as root - it will automatically request sudo permissions as needed.
Automatic updates work by `git pull`ing the latest version of the repo from Forgejo. This repo gets updated nightly by [`Hevana`](./hosts/Hevana), which updates the `flake.lock` file and pushes it back up to Forgejo. Only one host needs to do this, and you can enable this feature on a host using `aux.system.services.autoUpgrade.pushUpdates = true;`. #### Automatic updates
To enable automatic updates for a host, set `aux.system.services.autoUpgrade = true;`. You can configure the autoUpgrade module with additional settings, e.g.:
```nix
aux.system.services.autoUpgrade = {
enable = true;
configDir = config.secrets.nixConfigFolder;
extraFlags = "--build-host hevana";
onCalendar = "daily";
user = config.users.users.aires.name;
};
```
Automatic updates work by running `nos`. There's an additional `pushUpdates` option that, when enabled, updates the `flake.lock` file and pushes it back up to the Git repository. Only one host needs to do this (in this case, it's [Hevana](./hosts/Hevana), but you can safely enable it on multiple hosts as long as they use the same repository and update at different times.
#### Manually updating #### Manually updating
Run `nh` to update the system. Use the `--update` flag to update `flake.lock` as part of the process. After the first build, you can omit the hostname and path to your flake.nix file: Run `nos` to update the system. Use the `--update` flag to update `flake.lock` as part of the process. For the first build, you'll need to specify the path to your `flake.nix` file and the hostname using `nos --hostname my_hostname --flake /path/to/flake.nix`.
After the first build, you can omit the hostname and path:
```sh ```sh
nh os switch --update nos
``` ```
This is the equivalent of running: This is the equivalent of running:
```sh ```sh
nix flake update cd [flake dir]
git pull
nix flake update --commit-lock-file
git push
sudo nixos-rebuild switch --flake . sudo nixos-rebuild switch --flake .
``` ```

View file

@ -1,12 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Wrapper script for nixos-rebuild # The NixOS Operations Script (NOS) is a wrapper script for nixos-rebuild and Flake-based configurations.
# It handles pulling the latest version of your repository using Git, running system updates, and pushing changes back up.
# Configuration parameters # Configuration parameters
operation="switch" # The nixos-rebuild operation to use operation="switch" # The nixos-rebuild operation to use
hostname=$(/run/current-system/sw/bin/hostname) # The name of the host to build hostname=$(/run/current-system/sw/bin/hostname) # The name of the host to build
flakeDir="${FLAKE_DIR}" # Path to the flake file (and optionally the hostname). Defaults to the FLAKE_DIR environment variable. flakeDir="${FLAKE_DIR}" # Path to the flake file (and optionally the hostname)
update=false # Whether to update flake.lock (false by default) update=false # Whether to update and commmit flake.lock
user=$(/run/current-system/sw/bin/whoami) # Which user account to use for git commands (defaults to whoever called the script) user=$(/run/current-system/sw/bin/whoami) # Which user account to use for git commands
remainingArgs="" # All remaining arguments that haven't yet been processed (will be passed to nixos-rebuild) remainingArgs="" # All remaining arguments that haven't yet been processed (will be passed to nixos-rebuild)
function usage() { function usage() {
@ -16,15 +17,17 @@ function usage() {
echo " 1. Pull the latest version of your Nix config repository" echo " 1. Pull the latest version of your Nix config repository"
echo " 2. Run 'nixos-rebuild switch'." echo " 2. Run 'nixos-rebuild switch'."
echo "" echo ""
echo "Advanced usage: nixos-operations-script.sh [-o|--operation operation] [-f|--flake path-to-flake] [extra nixos-rebuild parameters]" echo "Advanced usage: nixos-operations-script.sh [-h | --hostname hostname-to-build] [-o | --operation operation] [-f | --flake path-to-flake] [extra nixos-rebuild parameters]"
echo "Options:"
echo " -h, --help Show this help screen."
echo " -o, --operation The nixos-rebuild operation to perform."
echo " -f, --flake <path> The path to your flake.nix file (and optionally, the hostname to build)."
echo " -U, --update Update and commit flake.lock."
echo " -u, --user Which user account to run git commands under."
echo "" echo ""
exit 2 echo "Options:"
echo " --help Show this help screen."
echo " -f, --flake [path] The path to your flake.nix file (defualts to the FLAKE_DIR environment variable)."
echo " -h, --hostname [hostname] The name of the host to build (defaults to the current system's hostname)."
echo " -o, --operation [operation] The nixos-rebuild operation to perform (defaults to 'switch')."
echo " -U, --update Update and commit the flake.lock file."
echo " -u, --user [username] Which user account to run git commands under (defaults to the user running this script)."
echo ""
exit 0
} }
# Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash # Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
@ -36,6 +39,11 @@ while [[ $# -gt 0 ]]; do
shift shift
shift shift
;; ;;
--hostname|-h)
hostname="$2"
shift
shift
;;
--update|--upgrade|-U) --update|--upgrade|-U)
update=true update=true
shift shift
@ -50,9 +58,8 @@ while [[ $# -gt 0 ]]; do
shift shift
shift shift
;; ;;
--help|-h) --help)
usage usage
exit 0
;; ;;
*) *)
POSITIONAL_ARGS+=("$1") # save positional arg POSITIONAL_ARGS+=("$1") # save positional arg
@ -80,9 +87,9 @@ else
echo "Skipping 'nix flake update'..." echo "Skipping 'nix flake update'..."
fi fi
options="--flake $flakeDir $remainingArgs --use-remote-sudo --log-format multiline-with-logs" options="--flake ${flakeDir}#${hostname} ${remainingArgs} --use-remote-sudo --log-format multiline-with-logs"
echo "Running this operation: nixos-rebuild $operation $options" echo "Running this operation: nixos-rebuild ${operation} ${options}"
/run/wrappers/bin/sudo -u root /run/current-system/sw/bin/nixos-rebuild $operation $options /run/wrappers/bin/sudo -u $user /run/current-system/sw/bin/nixos-rebuild $operation $options
exit 0 exit 0

View file

@ -203,7 +203,7 @@
"narHash": "sha256-5WHctvz0R9N9oBGda1ROuJ/V/m/tZsEXloGWDrd9G7Y=", "narHash": "sha256-5WHctvz0R9N9oBGda1ROuJ/V/m/tZsEXloGWDrd9G7Y=",
"rev": "866b8902c975a1aaec547445976dd39d60def4ab", "rev": "866b8902c975a1aaec547445976dd39d60def4ab",
"type": "tarball", "type": "tarball",
"url": "https://git.auxolotl.org/api/v1/repos/auxolotl/labs/archive/866b8902c975a1aaec547445976dd39d60def4ab.tar.gz?rev=866b8902c975a1aaec547445976dd39d60def4ab" "url": "https://git.auxolotl.org/api/v1/repos/auxolotl/labs/archive/d7762a5a78273ffb76da6f6902245983143f63f6.tar.gz?rev=d7762a5a78273ffb76da6f6902245983143f63f6"
}, },
"original": { "original": {
"dir": "lib", "dir": "lib",
@ -315,11 +315,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1728888510, "lastModified": 1728492678,
"narHash": "sha256-nsNdSldaAyu6PE3YUA+YQLqUDJh+gRbBooMMekZJwvI=", "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", "rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -331,11 +331,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1728909085, "lastModified": 1728740863,
"narHash": "sha256-WLxED18lodtQiayIPDE5zwAfkPJSjHJ35UhZ8h3cJUg=", "narHash": "sha256-u+rxA79a0lyhG+u+oPBRtTDtzz8kvkc9a6SWSt9ekVc=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c0b1da36f7c34a7146501f684e9ebdf15d2bebf8", "rev": "a3f9ad65a0bf298ed5847629a57808b97e6e8077",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -13,6 +13,7 @@
aux.system.packages = with pkgs; [ aux.system.packages = with pkgs; [
fastfetch # Show a neat system statistics screen when opening a terminal fastfetch # Show a neat system statistics screen when opening a terminal
htop # System monitor htop # System monitor
lm_sensors # System temperature monitoring
zellij # Terminal multiplexer zellij # Terminal multiplexer
]; ];

View file

@ -5,6 +5,12 @@ let
# LUKS partition will decrypt to /dev/mapper/nixos-root # LUKS partition will decrypt to /dev/mapper/nixos-root
decryptPart = "nixos-root"; decryptPart = "nixos-root";
decryptPath = "/dev/mapper/${decryptPart}"; decryptPath = "/dev/mapper/${decryptPart}";
# Default mount options for your main partitions
primaryPartOpts = [
"compress=zstd"
(lib.mkIf cfg.discard "discard=async").content
];
in in
{ {
options = { options = {
@ -56,56 +62,44 @@ in
# Enable TPM auto-unlocking if configured # Enable TPM auto-unlocking if configured
crypttabExtraOpts = lib.mkIf config.aux.system.bootloader.tpm2.enable [ "tpm2-device=auto" ]; crypttabExtraOpts = lib.mkIf config.aux.system.bootloader.tpm2.enable [ "tpm2-device=auto" ];
}; };
fileSystems = fileSystems = {
{ "/" = {
"/" = { device = decryptPath;
device = decryptPath; fsType = "btrfs";
fsType = "btrfs"; options = [ "subvol=@" ] ++ primaryPartOpts;
options = [
"subvol=@"
"compress=zstd"
] ++ lib.optionals cfg.discard [ "discard=async" ];
};
"/boot" = {
device = cfg.partitions.boot;
fsType = "vfat";
};
"/home" = {
device = decryptPath;
fsType = "btrfs";
options = [
"subvol=@home"
"compress=zstd"
] ++ lib.optionals cfg.discard [ "discard=async" ];
};
"/var/log" = {
device = decryptPath;
fsType = "btrfs";
options = [
"subvol=@log"
"compress=zstd"
] ++ lib.optionals cfg.discard [ "discard=async" ];
};
"/nix" = {
device = decryptPath;
fsType = "btrfs";
options = [
"subvol=@nix"
"compress=zstd"
"noatime"
] ++ lib.optionals cfg.discard [ "discard=async" ];
};
}
// lib.optionalAttrs cfg.swapFile.enable {
"/swap" = {
device = decryptPath;
fsType = "btrfs";
options = [
"subvol=@swap"
"noatime"
] ++ lib.optionals cfg.discard [ "discard=async" ];
};
}; };
"/boot" = {
device = cfg.partitions.boot;
fsType = "vfat";
};
"/home" = {
device = decryptPath;
fsType = "btrfs";
options = [ "subvol=@home" ] ++ primaryPartOpts;
};
"/var/log" = {
device = decryptPath;
fsType = "btrfs";
options = [ "subvol=@log" ] ++ primaryPartOpts;
};
"/nix" = {
device = decryptPath;
fsType = "btrfs";
options = [
"subvol=@nix"
"noatime"
] ++ primaryPartOpts;
};
"/swap" = lib.mkIf cfg.swapFile.enable {
device = decryptPath;
fsType = "btrfs";
options = [
"subvol=@swap"
"noatime"
(lib.mkIf cfg.discard "discard=async").content
];
};
};
swapDevices = lib.mkIf cfg.swapFile.enable [ swapDevices = lib.mkIf cfg.swapFile.enable [
{ {

View file

@ -32,10 +32,7 @@ in
gnutar gnutar
gzip gzip
home-manager home-manager
lm_sensors openssh
config.nix.package.out
nh
config.programs.ssh.package
sudo sudo
xz.bin xz.bin
]; ];

View file

@ -59,6 +59,7 @@ in
noto-fonts-emoji noto-fonts-emoji
liberation_ttf liberation_ttf
fira-code fira-code
fira-code-nerdfont
fira-code-symbols fira-code-symbols
fira fira
roboto-slab roboto-slab

View file

@ -87,16 +87,13 @@ in
matchBlocks = config.secrets.users.aires.sshConfig; matchBlocks = config.secrets.users.aires.sshConfig;
}; };
# Set up Zsh # Tweak Zsh
zsh = { zsh = {
oh-my-zsh = {
theme = "gentoo";
};
shellAliases = { shellAliases = {
nos = "nixos-operations-script"; nos = "nixos-operations-script";
z = "zellij"; z = "zellij";
update = "upgrade"; update = "upgrade";
upgrade = "nos"; upgrade = "nos --update";
}; };
loginExtra = "fastfetch --memory-percent-green 75 --memory-percent-yellow 90"; loginExtra = "fastfetch --memory-percent-green 75 --memory-percent-yellow 90";
}; };

View file

@ -1,29 +1,24 @@
# Additional ZSH settings via Home Manager # Additional ZSH settings via Home Manager
{ pkgs, ... }: { pkgs, ... }:
{ {
programs.zsh = { programs = {
enable = true; # Set up Starship
autosuggestion.enable = true; # https://starship.rs/
syntaxHighlighting.enable = true; starship = {
history.ignoreDups = true; # Do not enter command lines into the history list if they are duplicates of the previous event.
prezto = {
git.submoduleIgnore = "untracked"; # Ignore submodules when they are untracked.
};
plugins = [
{
name = "zsh-nix-shell";
file = "nix-shell.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "chisui";
repo = "zsh-nix-shell";
rev = "v0.8.0";
sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7";
};
}
];
oh-my-zsh = {
enable = true; enable = true;
plugins = [ "git" ]; enableZshIntegration = true;
};
zsh = {
enable = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
history.ignoreDups = true; # Do not enter command lines into the history list if they are duplicates of the previous event.
initExtra = ''
function set_win_title(){
echo -ne "\033]0; $(basename "$PWD") \007"
}
precmd_functions+=(set_win_title)
'';
}; };
}; };
} }

View file

@ -90,23 +90,6 @@ in
enable = true; enable = true;
matchBlocks = config.secrets.users.gremlin.sshConfig; matchBlocks = config.secrets.users.gremlin.sshConfig;
}; };
# Set up Zsh
zsh = {
# Install and source the p10k theme
plugins = [
{
name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
{
name = "powerlevel10k-config";
src = ./p10k-config;
file = "p10k.zsh";
}
];
};
}; };
}; };
}) })

File diff suppressed because it is too large Load diff