From ae8398e05ea5dca6cd7c445a9b0f14aec8d1e7d1 Mon Sep 17 00:00:00 2001 From: iFargle Date: Wed, 4 Oct 2023 19:51:02 +0900 Subject: [PATCH] Update installer for sparse checkout --- .forgejo/workflows/update-flake-lock.yml | 2 - README.md | 7 ++++ flake.nix | 2 +- lib/default.nix | 16 +++++++ nixos/common/modules/installer.nix | 7 +++- .../default.nix | 2 +- .../disks.nix | 0 nixos/vultr.nix | 42 +++++++++++++++++++ 8 files changed, 72 insertions(+), 6 deletions(-) rename nixos/hosts/{nixos-osaka-vultr-01 => osaka-vultr-01}/default.nix (93%) rename nixos/hosts/{nixos-osaka-vultr-01 => osaka-vultr-01}/disks.nix (100%) create mode 100644 nixos/vultr.nix diff --git a/.forgejo/workflows/update-flake-lock.yml b/.forgejo/workflows/update-flake-lock.yml index 783d836f..bd63a856 100644 --- a/.forgejo/workflows/update-flake-lock.yml +++ b/.forgejo/workflows/update-flake-lock.yml @@ -22,8 +22,6 @@ jobs: --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ git config --global user.email "${{github.actor}}" git config --global user.name "Albert J. Copeland" - echo "TEST: ${{ secrets.TEST_SECRET }}" - echo "TOKEN: ${{ secrets.GITHUB_TOKEN }}" - uses: https://code.forgejo.org/actions/checkout@v3 with: sparse-checkout: | diff --git a/README.md b/README.md index f65a040e..c17a6dda 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,13 @@ nixos-install [] ``` nix develop -c /etc/nixos/git/docs/setup.sh ``` +* Sparse Checkout (for low RAM environments): +``` +git clone --filter=blob:none --no-checkout https://git.sysctl.io/albert/nix git/ +cd git/ +git sparse-checkout set --cone docs/ home-manager/ keys/ssh/ lib/ nixos/ flake.lock flake.nix shell.nix +git checkout main +``` ![Gruv'd Hyprland](./docs/screenshot.png "Hyprland with a Gruvboxy theme") --- diff --git a/flake.nix b/flake.nix index f6df51ce..8477501e 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,7 @@ in { nixosConfigurations = { # Virtual Machines + osaka-vultr-01 = lib.mkMinHost { hostname = "osaka-vultr-01"; }; nixos-vm-01 = libx.mkHost { hostname = "nixos-vm-01"; }; nixos-vm-02 = libx.mkHost { hostname = "nixos-vm-02"; desktop = "hyprland"; gpu = "intel"; theme = "gruvbox"; }; # Physical Machines @@ -46,7 +47,6 @@ nixos-rpi4-02 = libx.mkHost { hostname = "nixos-rpi4-02"; platform = "aarch64-linux"; }; nixos-rpi4-03 = libx.mkHost { hostname = "nixos-rpi4-03"; platform = "aarch64-linux"; }; }; - homeConfigurations = { # Virtual Machines "albert@nixos-vm-01" = libx.mkHome { hostname = "nixos-vm-01"; }; diff --git a/lib/default.nix b/lib/default.nix index 84aaf415..2be33b83 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -32,6 +32,22 @@ ]; }; + # Helper function for generating host configs + mkHost = { + hostname, + username ? "albert", + desktop ? null, + gpu ? null, + platform ? "x86_64-linux", + theme ? "default" + }: inputs.nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs desktop hostname username stateVersion gpu platform theme; }; + modules = [ + ../nixos/minimal.nix + inputs.sops-nix.nixosModules.sops + ]; + }; + # Combines mkHost and mkHome for image building mkImage = { hostname , diff --git a/nixos/common/modules/installer.nix b/nixos/common/modules/installer.nix index 9e4ffa08..b23a699d 100644 --- a/nixos/common/modules/installer.nix +++ b/nixos/common/modules/installer.nix @@ -15,10 +15,13 @@ if [ "$(id -u)" -eq 0 ]; then fi if [ ! -d "/tmp/nixos/git/.git" ]; then - git clone https://git.sysctl.io/albert/nix "/tmp/nixos/git" + git clone --filter=blob:none --no-checkout https://git.sysctl.io/albert/nix "/tmp/nixos/git" + cd /tmp/nixos/git + git sparse-checkout set --cone docs/ home-manager/ keys/ssh/ lib/ nixos/ flake.lock flake.nix shell.nix + git checkout main fi -pushd "/tmp/nixos/git" +pushd /tmp/nixos/git if [[ -z "$TARGET_HOST" ]]; then echo "ERROR! $(basename "$0") requires a hostname as the first argument" diff --git a/nixos/hosts/nixos-osaka-vultr-01/default.nix b/nixos/hosts/osaka-vultr-01/default.nix similarity index 93% rename from nixos/hosts/nixos-osaka-vultr-01/default.nix rename to nixos/hosts/osaka-vultr-01/default.nix index 6ffd4ecb..0d142f87 100644 --- a/nixos/hosts/nixos-osaka-vultr-01/default.nix +++ b/nixos/hosts/osaka-vultr-01/default.nix @@ -13,7 +13,7 @@ networking.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; time.timeZone = "Asia/Tokyo"; - networking.hostName = "nixos-osaka-vultr-01"; + networking.hostName = "osaka-vultr-01"; boot.loader.grub = { enableCryptodisk = true; diff --git a/nixos/hosts/nixos-osaka-vultr-01/disks.nix b/nixos/hosts/osaka-vultr-01/disks.nix similarity index 100% rename from nixos/hosts/nixos-osaka-vultr-01/disks.nix rename to nixos/hosts/osaka-vultr-01/disks.nix diff --git a/nixos/vultr.nix b/nixos/vultr.nix new file mode 100644 index 00000000..b62e4252 --- /dev/null +++ b/nixos/vultr.nix @@ -0,0 +1,42 @@ +{ lib, config, pkgs, hostname, stateVersion, username, desktop, gpu, inputs, platform, theme, ... }: { + imports = [ + # Services + ./common/services/openssh.nix + ./common/services/fail2ban.nix + + # NixOS Modules + ./common/modules/networking.nix # Initial Networking configs + ./common/modules/nixos.nix # NixOS related items + + ./users/${username} + ./hosts/${hostname} + ]; + + # List packages installed in system profile + environment.systemPackages = with pkgs; [ + curl + rsync + git + duf + ncdu + du-dust + sops + gnupg + ]; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + system.stateVersion = stateVersion; +}