Skip to content

Commit

Permalink
fixup! Migrate nixos-install to btrfs
Browse files Browse the repository at this point in the history
  • Loading branch information
rake5k committed Sep 8, 2023
1 parent dac1dab commit fcfc038
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ this flake to the inputs and define your hosts and users in the `flake.nix`:
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
nixcfg.url = "github:christianharke/nixcfg";
nixcfg.url = "github:rake5k/nixcfg";
};
outputs = { nixpkgs, nixcfg, ... } @ inputs:
Expand Down Expand Up @@ -134,7 +134,7 @@ sudo su # become root
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf

nix run github:christianharke/nixcfg#nixos-install -- <hostname> <disk>
nix run github:rake5k/nixcfg#nixos-install -- <hostname> <disk> github:rake5k/nixcfg-home
```

Where:
Expand All @@ -155,7 +155,7 @@ After rebooting proceed with the [next section](#nixos-config-setup).
#### NixOS config setup

```bash
$ sudo nix run github:christianharke/nixcfg#setup
$ sudo nix run github:rake5k/nixcfg#setup
```

### Non-NixOS
Expand All @@ -174,7 +174,7 @@ sh <(curl -L https://nixos.org/nix/install) --no-channel-add --no-modify-profile

```bash
# Set up this Nix configuration
nix run github:christianharke/nixcfg#setup
nix run github:rake5k/nixcfg#setup

# set login shell
chsh -s /bin/zsh
Expand Down Expand Up @@ -234,10 +234,10 @@ $ # On non-NixOS
$ hm-switch
```

[ci]: https://github.com/christianharke/nixcfg/actions/workflows/ci.yml
[ci-badge]: https://github.com/christianharke/nixcfg/actions/workflows/ci.yml/badge.svg
[update]: https://github.com/christianharke/nixcfg/actions/workflows/update.yml
[update-badge]: https://github.com/christianharke/nixcfg/actions/workflows/update.yml/badge.svg
[ci]: https://github.com/rake5k/nixcfg/actions/workflows/ci.yml
[ci-badge]: https://github.com/rake5k/nixcfg/actions/workflows/ci.yml/badge.svg
[update]: https://github.com/rake5k/nixcfg/actions/workflows/update.yml
[update-badge]: https://github.com/rake5k/nixcfg/actions/workflows/update.yml/badge.svg

[age]: https://age-encryption.org/
[agenix]: https://github.com/ryantm/agenix
Expand Down
20 changes: 10 additions & 10 deletions flake/apps/nixos-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source @bashLib@

readonly HOSTNAME="${1}"
readonly DISK="${2}"
readonly FLAKE="${3}"

# Validate arguments

Expand Down Expand Up @@ -49,7 +50,7 @@ readonly ROOT_PARTITION
### Declare functions

readonly ROOT_CRYPT="root-crypt"
readonly BOOT_FS="boot"
readonly BOOT_FS="BOOT"
readonly ROOT_FS="root"
readonly MOUNT_ROOT="/mnt"

Expand Down Expand Up @@ -118,20 +119,19 @@ enable_swap() {
local swap_dir="${MOUNT_ROOT}/swap"
local swap_file="${swap_dir}/swapfile"

_log "[create_filesystems] Creating swap file..."
touch "${swap_file}"
chattr +C "${swap_file}"
dd if=/dev/zero of="${swap_file}" bs=1M count=4096
chmod 0600 "${swap_file}"
mkswap "${swap_file}"
_log "[enable_swap] Creating swap file..."
btrfs filesystem mkswapfile --size 4G "${swap_file}"

_log "[enable_swap] Enabling swap..."
swapon -v "${swap_file}"
swapon "${swap_file}"

_log "[enable_swap] Enabled swaps:"
cat /proc/swaps
}

install() {
_log "[install] Installing NixOS..."
nixos-install --root "${MOUNT_ROOT}" --flake "github:christianharke/nixcfg#${HOSTNAME}" --impure
nixos-install --root "${MOUNT_ROOT}" --flake "${FLAKE}#${HOSTNAME}" --impure
_log "[install] Installing NixOS... finished!"

_log "[install] Installation finished, please reboot and remove installation media..."
Expand All @@ -148,7 +148,7 @@ fi

CRYPT_VOL_STATUS="$(cryptsetup -q status "${ROOT_CRYPT}")"
readonly CRYPT_VOL_STATUS
CRYPT_VOL_NUM_ACTIVE=$(echo "${CRYPT_VOL_STATUS}" | grep "^/dev/mapper/${ROOT_CRYPT} is active and is in use.$" -c)
CRYPT_VOL_NUM_ACTIVE=$(echo "${CRYPT_VOL_STATUS}" | grep "^/dev/mapper/${ROOT_CRYPT} is active.$" -c)
readonly CRYPT_VOL_NUM_ACTIVE
if [[ ${CRYPT_VOL_NUM_ACTIVE} -lt 1 ]]; then
decrypt_volumes
Expand Down

0 comments on commit fcfc038

Please sign in to comment.