diff --git a/.vscode/settings.json b/.vscode/settings.json index 011a2f3..3ff1b12 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { - "direnv.path.executable": "/run/current-system/sw/bin/direnv", - "direnv.restart.automatic": true, - "nix.enableLanguageServer": true, - "nix.serverPath": "/run/current-system/sw/bin/nil", - "nix.formatterPath": "/run/current-system/sw/bin/nix fmt", + "direnv.path.executable": "/run/current-system/sw/bin/direnv", + "direnv.restart.automatic": true, + "nix.enableLanguageServer": true, + "nix.serverPath": "/run/current-system/sw/bin/nil", + "nix.formatterPath": "/run/current-system/sw/bin/nix fmt" } diff --git a/README.md b/README.md index 95d6aea..42c977b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Secrets are managed using [git-crypt](https://github.com/AGWA/git-crypt). To unl 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 -./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. Running `format-drives.sh` also generates a `hardware-configuration.nix` file you can use. @@ -30,7 +30,7 @@ Finally, run the NixOS installer, replacing `host` with your actual hostname: ```sh sudo nixos-install --verbose --root /mnt --flake .#host --no-root-password -``` +``` > [!TIP] > 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`. @@ -66,7 +66,7 @@ nos This is the equivalent of running: -```sh +```sh cd [flake dir] git pull nix flake update --commit-lock-file @@ -130,10 +130,11 @@ nixos-rebuild build-vm --flake . ### Layout This config uses a custom templating system built off of the [Auxolotl system templates](https://git.auxolotl.org/auxolotl/templates). + - Flakes are the entrypoint, via `flake.nix`. This is where Flake inputs and Flake-specific options get defined. - Hosts are defined in the `hosts` folder. - Modules are defined in `modules`. All of these files are automatically imported (except home-manager modules). You simply enable the ones you want to use, and disable the ones you don't. For example, to install Flatpak support, set `aux.system.ui.flatpak.enable = true;`. - - After adding a new module, make sure to `git add` it before running `nixos-rebuild`. + - After adding a new module, make sure to `git add` it before running `nixos-rebuild`. - Home-manager configs live in the `users/` folders. ### Features diff --git a/bin/compile-manuscript.sh b/bin/compile-manuscript.sh index 7631c13..d9264b3 100755 --- a/bin/compile-manuscript.sh +++ b/bin/compile-manuscript.sh @@ -8,16 +8,16 @@ outDir="./out" metadataFile="$inDir/metadata.yml" function usage() { - echo "Compile a directory of Markdown (.md) files into DOCX, ePub, and PDF files." - echo "" - echo "Options:" - echo " --help Show this help screen." - echo " -n, --name [name] The name of this draft." - echo " -i, --input [path] Directory containing the files to convert. Defaults to this directory." - echo " -o, --output [path] Directory to store the converted files in. Defaults to ./out." - echo " -m, --metadata [path] Path to the YAML file containing metadata for pandoc." - echo "" - exit 0 + echo "Compile a directory of Markdown (.md) files into DOCX, ePub, and PDF files." + echo "" + echo "Options:" + echo " --help Show this help screen." + echo " -n, --name [name] The name of this draft." + echo " -i, --input [path] Directory containing the files to convert. Defaults to this directory." + echo " -o, --output [path] Directory to store the converted files in. Defaults to ./out." + echo " -m, --metadata [path] Path to the YAML file containing metadata for pandoc." + echo "" + exit 0 } # Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash @@ -25,47 +25,47 @@ POSITIONAL_ARGS=() while [[ $# -gt 0 ]]; do case "$1" in --draft-name|--name|-n) - draftName="$2" - shift - shift - ;; + draftName="$2" + shift + shift + ;; --input|--indir|-i) - inDir="$2" - shift - shift - ;; + inDir="$2" + shift + shift + ;; --output|--outdir|-o) - outDir="$2" - shift - shift - ;; + outDir="$2" + shift + shift + ;; --metadata|--metadataFile|-m) - metadataFile="$2" - shift - shift - ;; + metadataFile="$2" + shift + shift + ;; --help) - usage - ;; + usage + ;; *) - POSITIONAL_ARGS+=("$1") # save positional arg - shift - ;; - esac + POSITIONAL_ARGS+=("$1") # save positional arg + shift + ;; + esac done remainingArgs=${POSITIONAL_ARGS[@]} set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters # If this is a git repo and no name has been provided, name the draft after the current branch if [ -d ".git" ] && [ "$draftName" = "draft" ]; then - draftName=$(git rev-parse --abbrev-ref HEAD) + draftName=$(git rev-parse --abbrev-ref HEAD) fi # Check if this directory already exists outDir="$outDir/${draftName}" if [ -d $outDir ]; then - echo "The folder $outDir already exists." - read -p "Enter YES to overwrite, or Ctrl-C to cancel: " confirm && [ $confirm = "YES" ] || exit 1 + echo "The folder $outDir already exists." + read -p "Enter YES to overwrite, or Ctrl-C to cancel: " confirm && [ $confirm = "YES" ] || exit 1 fi draftFile="$outDir/${draftName}" @@ -82,11 +82,11 @@ echo > $draftFile.md # Obsidian specifically creates "folder notes," which are named for the directory, so we make sure to exclude it. find "$inDir" -type f -wholename "* *.md" ! -name content.md -print0 | sort -z | while read -d $'\0' file do - # Add newline to Markdown doc - echo >> $draftFile.md - # Clean up incoming Markdown and append it to final doc - sed "s|(../|($inDir/../|g" "$file" >> $draftFile.md - echo "\\newpage" >> $draftFile.md + # Add newline to Markdown doc + echo >> $draftFile.md + # Clean up incoming Markdown and append it to final doc + sed "s|(../|($inDir/../|g" "$file" >> $draftFile.md + echo "\\newpage" >> $draftFile.md done # Generate the output files: diff --git a/bin/format-drives.sh b/bin/format-drives.sh index f1fc93f..332f536 100755 --- a/bin/format-drives.sh +++ b/bin/format-drives.sh @@ -6,8 +6,8 @@ set -e if [ "$(id -u)" != "0" ]; then - echo "This script must be run as root" 1>&2 - exit 1 + echo "This script must be run as root" 1>&2 + exit 1 fi # Configuration parameters @@ -17,42 +17,42 @@ luks_partition="" # The drive partition to create the LUKS container on root_partition="/dev/mapper/nixos-crypt" # The partition to install NixOS to function usage() { - echo "Usage: format-drives.sh [--boot boot-partition-path] [--luks luks-partition-path] [--ask-root-password]" - echo "Options:" - echo " -h | --help Show this help screen." - echo " -b | --boot The path to the boot drive (e.g. /dev/nvme0n1p1)." - echo " -l | --luks The path to the partition to create the LUKS container on (e.g. /dev/nvme0n1p2)." - echo " -a | --ask-root-password Sets a password for the root user account." - exit 2 + echo "Usage: format-drives.sh [--boot boot-partition-path] [--luks luks-partition-path] [--ask-root-password]" + echo "Options:" + echo " -h | --help Show this help screen." + echo " -b | --boot The path to the boot drive (e.g. /dev/nvme0n1p1)." + echo " -l | --luks The path to the partition to create the LUKS container on (e.g. /dev/nvme0n1p2)." + echo " -a | --ask-root-password Sets a password for the root user account." + exit 2 } # Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash POSITIONAL_ARGS=() while [[ $# -gt 0 ]]; do case "$1" in - --ask-root-password|-a) - ask_root_password=true - shift - ;; - --boot|-b) - boot_partition="$2" - shift - shift - ;; - --luks|-l) - luks_partition="$2" - shift - shift - ;; - --help|-h) - usage - shift - ;; - *) - POSITIONAL_ARGS+=("$1") # save positional arg - shift # past argument - ;; - esac + --ask-root-password|-a) + ask_root_password=true + shift + ;; + --boot|-b) + boot_partition="$2" + shift + shift + ;; + --luks|-l) + luks_partition="$2" + shift + shift + ;; + --help|-h) + usage + shift + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac done set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters diff --git a/bin/nixos-operations-script.sh b/bin/nixos-operations-script.sh index 3382bfe..b5cb669 100755 --- a/bin/nixos-operations-script.sh +++ b/bin/nixos-operations-script.sh @@ -12,73 +12,73 @@ buildHost="" # Which host to use to generate remainingArgs="" # All remaining arguments that haven't yet been processed (will be passed to nixos-rebuild) function usage() { - echo "The NixOS Operations Script (NOS) is a nixos-rebuild wrapper for system maintenance." - echo "" - echo "Running the script with no parameters performs the following operations:" - echo " 1. Pull the latest version of your Nix config repository" - echo " 2. Run 'nixos-rebuild switch'." - echo "" - 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 "" - 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 + echo "The NixOS Operations Script (NOS) is a nixos-rebuild wrapper for system maintenance." + echo "" + echo "Running the script with no parameters performs the following operations:" + echo " 1. Pull the latest version of your Nix config repository" + echo " 2. Run 'nixos-rebuild switch'." + echo "" + 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 "" + 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 POSITIONAL_ARGS=() while [[ $# -gt 0 ]]; do case "$1" in - --build-host) - buildHost="$2" - shift - shift - ;; - --flake|-f) - flakeDir="$2" - shift - shift - ;; - --hostname|-h) - hostname="$2" - shift - shift - ;; - --update|--upgrade|-U) - update=true - shift - ;; - --operation|-o) - operation="$2" - shift - shift - ;; - --user|-u) - user="$2" - shift - shift - ;; - --help) - usage - ;; - *) - POSITIONAL_ARGS+=("$1") # save positional arg - shift - ;; - esac + --build-host) + buildHost="$2" + shift + shift + ;; + --flake|-f) + flakeDir="$2" + shift + shift + ;; + --hostname|-h) + hostname="$2" + shift + shift + ;; + --update|--upgrade|-U) + update=true + shift + ;; + --operation|-o) + operation="$2" + shift + shift + ;; + --user|-u) + user="$2" + shift + shift + ;; + --help) + usage + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift + ;; + esac done remainingArgs=${POSITIONAL_ARGS[@]} set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters if [ -z "${flakeDir}" ]; then - echo "Flake directory not specified. Use '--flake ' or set \$FLAKE_DIR." - exit 1 + echo "Flake directory not specified. Use '--flake ' or set \$FLAKE_DIR." + exit 1 fi cd $flakeDir @@ -87,19 +87,19 @@ echo "Pulling the latest version of the repository..." /run/wrappers/bin/sudo -u $user /run/current-system/sw/bin/git pull if [ $update = true ]; then - echo "Updating flake.lock..." - /run/wrappers/bin/sudo -u $user /run/current-system/sw/bin/nix flake update --commit-lock-file - /run/wrappers/bin/sudo -u $user git push + echo "Updating flake.lock..." + /run/wrappers/bin/sudo -u $user /run/current-system/sw/bin/nix flake update --commit-lock-file + /run/wrappers/bin/sudo -u $user git push else - echo "Skipping 'nix flake update'..." + echo "Skipping 'nix flake update'..." fi options="--flake ${flakeDir}#${hostname} ${remainingArgs} --use-remote-sudo --log-format multiline-with-logs" if [[ -n "${buildHost}" && $operation != "build" && $operation != *"dry"* ]]; then - echo "Remote build detected, running this operation first: nixos-rebuild build ${options} --build-host $buildHost" - /run/current-system/sw/bin/nixos-rebuild build $options --build-host $buildHost - echo "Remote build complete!" + echo "Remote build detected, running this operation first: nixos-rebuild build ${options} --build-host $buildHost" + /run/current-system/sw/bin/nixos-rebuild build $options --build-host $buildHost + echo "Remote build complete!" fi echo "Running this operation: nixos-rebuild ${operation} ${options}" diff --git a/flake.lock b/flake.lock index 0d26caf..1e4f53b 100644 --- a/flake.lock +++ b/flake.lock @@ -58,6 +58,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -97,6 +113,25 @@ "type": "github" } }, + "flake-utils-plus": { + "inputs": { + "flake-utils": "flake-utils_3" + }, + "locked": { + "lastModified": 1715533576, + "narHash": "sha256-fT4ppWeCJ0uR300EH3i7kmgRZnAVxrH+XtK09jQWihk=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "3542fe9126dc492e53ddd252bb0260fe035f2c0f", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "3542fe9126dc492e53ddd252bb0260fe035f2c0f", + "type": "github" + } + }, "flake-utils_2": { "inputs": { "systems": "systems_2" @@ -115,6 +150,24 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "flakey-profile": { "locked": { "lastModified": 1712898590, @@ -198,21 +251,6 @@ "type": "github" } }, - "lib": { - "locked": { - "dir": "lib", - "lastModified": 1728413071, - "narHash": "sha256-5WHctvz0R9N9oBGda1ROuJ/V/m/tZsEXloGWDrd9G7Y=", - "rev": "866b8902c975a1aaec547445976dd39d60def4ab", - "type": "tarball", - "url": "https://git.auxolotl.org/api/v1/repos/auxolotl/labs/archive/866b8902c975a1aaec547445976dd39d60def4ab.tar.gz?rev=866b8902c975a1aaec547445976dd39d60def4ab" - }, - "original": { - "dir": "lib", - "type": "tarball", - "url": "https://git.auxolotl.org/auxolotl/labs/archive/main.tar.gz" - } - }, "lix": { "flake": false, "locked": { @@ -379,12 +417,13 @@ "auto-cpufreq": "auto-cpufreq", "home-manager": "home-manager", "lanzaboote": "lanzaboote", - "lib": "lib", "lix-module": "lix-module", "nix-flatpak": "nix-flatpak", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_2", - "nixpkgs-unstable": "nixpkgs-unstable" + "nixpkgs-unstable": "nixpkgs-unstable", + "snowfall-lib": "snowfall-lib", + "treefmt-nix": "treefmt-nix" } }, "rust-overlay": { @@ -412,6 +451,28 @@ "type": "github" } }, + "snowfall-lib": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils-plus": "flake-utils-plus", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1732544274, + "narHash": "sha256-qvzLIxuqukl0nxpXHEh5+iw1BLeLxYOwRC0+7cFUbPo=", + "owner": "snowfallorg", + "repo": "lib", + "rev": "cfeacd055545ab5de0ecfd41e09324dcd8fb2bbb", + "type": "github" + }, + "original": { + "owner": "snowfallorg", + "repo": "lib", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -441,6 +502,41 @@ "repo": "default", "type": "github" } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733222881, + "narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "49717b5af6f80172275d47a418c9719a31a78b53", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index d8f4654..f6993e4 100644 --- a/flake.nix +++ b/flake.nix @@ -25,9 +25,6 @@ # SecureBoot support lanzaboote.url = "github:nix-community/lanzaboote/v0.4.1"; - # Aux lib - lib.url = "https://git.auxolotl.org/auxolotl/labs/archive/main.tar.gz?dir=lib"; - # Use Lix in place of Nix. # If you'd rather use regular Nix, remove `lix-module.nixosModules.default` from the `modules` section below. # To learn more about Lix, see https://lix.systems/ @@ -41,97 +38,110 @@ # NixOS hardware quirks nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + + # Snowfall - a unified configuration manager for NixOS + # Quickstart guide: https://snowfall.org/guides/lib/quickstart/ + # Jake's reference config: https://github.com/jakehamilton/config + snowfall-lib = { + url = "github:snowfallorg/lib"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = - inputs@{ - auto-cpufreq, - home-manager, - lanzaboote, - lix-module, - nix-flatpak, - nixos-hardware, - nixpkgs, - ... - }: + inputs: let - forAllSystems = - function: - nixpkgs.lib.genAttrs [ - "x86_64-linux" - "aarch64-linux" - ] (system: function nixpkgs.legacyPackages.${system}); + lib = inputs.snowfall-lib.mkLib { + inherit inputs; - # Define shared modules and imports - defaultModules = [ - ./modules/autoimport.nix - auto-cpufreq.nixosModules.default - lix-module.nixosModules.default - lanzaboote.nixosModules.lanzaboote - nix-flatpak.nixosModules.nix-flatpak - home-manager.nixosModules.home-manager - { - _module.args = { - inherit inputs; + # Root dir for flake.nix + src = ./.; + + # Configure Snowfall + snowfall = { + # Choose a namespace to use for your flake's packages, library, and overlays. + namespace = "Sapana"; + + # Add flake metadata that can be processed by tools like Snowfall Frost. + meta = { + # A slug to use in documentation when displaying things like file paths. + name = "aires-flake"; + + # A title to show for your flake, typically the name. + title = "Aires' Flake"; }; - home-manager = { - /* - When running, Home Manager will use the global package cache. - It will also back up any files that it would otherwise overwrite. - The originals will have the extension shown below. - */ - useGlobalPkgs = true; - useUserPackages = true; - backupFileExtension = "home-manager-backup"; - }; - } - ]; + }; + }; in - { - formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); + lib.mkFlake { + # Configure Nix channels + channels-config.allowUnfree = true; - nixosConfigurations = { + # Define systems + systems = { + # Modules to import for all systems + modules.nixos = with inputs; [ + ./modules/autoimport.nix + auto-cpufreq.nixosModules.default + lix-module.nixosModules.default + lanzaboote.nixosModules.lanzaboote + nix-flatpak.nixosModules.nix-flatpak + home-manager.nixosModules.home-manager + { + _module.args = { + inherit inputs; + }; + home-manager = { + /* + When running, Home Manager will use the global package cache. + It will also back up any files that it would otherwise overwrite. + The originals will have the extension shown below. + */ + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "home-manager-backup"; + }; + } + ]; - Dimaga = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = defaultModules ++ [ + # Individual host configurations + hosts = { + Dimaga.modules = with inputs; [ nixos-hardware.nixosModules.common-cpu-intel ./hosts/Dimaga ]; - }; - Hevana = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = defaultModules ++ [ + Hevana.modules = with inputs; [ nixos-hardware.nixosModules.common-cpu-amd-pstate nixos-hardware.nixosModules.common-gpu-amd ./hosts/Hevana ]; - }; - Khanda = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = defaultModules ++ [ + Khanda.modules = with inputs; [ nixos-hardware.nixosModules.microsoft-surface-pro-9 ./hosts/Khanda ]; - }; - Pihole = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - modules = defaultModules ++ [ + Pihole.modules = with inputs; [ nixos-hardware.nixosModules.raspberry-pi-4 ./hosts/Pihole ]; - }; - Shura = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = defaultModules ++ [ + Shura.modules = with inputs; [ nixos-hardware.nixosModules.lenovo-legion-16arha7 ./hosts/Shura ]; }; }; + + # Use treefmt to format project repo + outputs-builder = channels: { + formatter = (inputs.treefmt-nix.lib.evalModule channels.nixpkgs ./treefmt.nix).config.build.wrapper; + }; }; } diff --git a/modules/common.nix b/modules/common.nix index a3a3959..346ad5e 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -6,16 +6,18 @@ }: { - # Install base packages - aux.system.packages = with pkgs; [ - fastfetch # Show a neat system statistics screen when opening a terminal - htop # System monitor - lm_sensors # System temperature monitoring - zellij # Terminal multiplexer - ]; + aux.system = { + # Install base packages + packages = with pkgs; [ + fastfetch # Show a neat system statistics screen when opening a terminal + htop # System monitor + lm_sensors # System temperature monitoring + zellij # Terminal multiplexer + ]; - # Install the nos helper script - aux.system.nixos-operations-script.enable = true; + # Install the nos helper script + nixos-operations-script.enable = true; + }; # Allow packages from the unstable repo by using 'pkgs.unstable' nixpkgs.overlays = [ diff --git a/hosts/Pihole/default.nix b/systems/aarch64-linux/Pihole/default.nix similarity index 100% rename from hosts/Pihole/default.nix rename to systems/aarch64-linux/Pihole/default.nix diff --git a/hosts/Pihole/hardware-configuration.nix b/systems/aarch64-linux/Pihole/hardware-configuration.nix similarity index 100% rename from hosts/Pihole/hardware-configuration.nix rename to systems/aarch64-linux/Pihole/hardware-configuration.nix diff --git a/hosts/configuration.nix.template b/systems/configuration.nix.template similarity index 100% rename from hosts/configuration.nix.template rename to systems/configuration.nix.template diff --git a/hosts/hardware-configuration.nix.template b/systems/hardware-configuration.nix.template similarity index 100% rename from hosts/hardware-configuration.nix.template rename to systems/hardware-configuration.nix.template diff --git a/hosts/Hevana/default.nix b/systems/x86_64-linux/Hevana/default.nix similarity index 100% rename from hosts/Hevana/default.nix rename to systems/x86_64-linux/Hevana/default.nix diff --git a/hosts/Hevana/etc/apcupsd.conf b/systems/x86_64-linux/Hevana/etc/apcupsd.conf similarity index 100% rename from hosts/Hevana/etc/apcupsd.conf rename to systems/x86_64-linux/Hevana/etc/apcupsd.conf diff --git a/hosts/Hevana/hardware-configuration.nix b/systems/x86_64-linux/Hevana/hardware-configuration.nix similarity index 100% rename from hosts/Hevana/hardware-configuration.nix rename to systems/x86_64-linux/Hevana/hardware-configuration.nix diff --git a/hosts/Khanda/default.nix b/systems/x86_64-linux/Khanda/default.nix similarity index 100% rename from hosts/Khanda/default.nix rename to systems/x86_64-linux/Khanda/default.nix diff --git a/hosts/Khanda/hardware-configuration.nix b/systems/x86_64-linux/Khanda/hardware-configuration.nix similarity index 100% rename from hosts/Khanda/hardware-configuration.nix rename to systems/x86_64-linux/Khanda/hardware-configuration.nix diff --git a/hosts/Shura/default.nix b/systems/x86_64-linux/Shura/default.nix similarity index 100% rename from hosts/Shura/default.nix rename to systems/x86_64-linux/Shura/default.nix diff --git a/hosts/Shura/hardware-configuration.nix b/systems/x86_64-linux/Shura/hardware-configuration.nix similarity index 100% rename from hosts/Shura/hardware-configuration.nix rename to systems/x86_64-linux/Shura/hardware-configuration.nix diff --git a/hosts/Shura/monitors.xml b/systems/x86_64-linux/Shura/monitors.xml similarity index 100% rename from hosts/Shura/monitors.xml rename to systems/x86_64-linux/Shura/monitors.xml diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..dc91ddb --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,15 @@ +# Configure formatter for .nix and other repo files +{ pkgs, ... }: +{ + projectRootFile = "flake.nix"; + + programs = { + beautysh.enable = true; + nixfmt = { + enable = true; + package = pkgs.nixfmt-rfc-style; + }; + prettier.enable = true; + yamlfmt.enable = true; + }; +}