From dccabe82e4ea56da42793321e5199f9305fad7a7 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 31 Jul 2024 23:43:50 +0300 Subject: [PATCH] Update Makefile & move bootstrap to a separate script. --- Bootstrap.sh | 41 +++++++++++++++++ Makefile | 63 +++++++++++++++----------- config/Wallpaper.nix | 4 +- home/config/tmux/module/Config.nix | 2 +- home/program/bash/module/Bootstrap.nix | 45 ------------------ 5 files changed, 80 insertions(+), 75 deletions(-) create mode 100755 Bootstrap.sh delete mode 100644 home/program/bash/module/Bootstrap.nix diff --git a/Bootstrap.sh b/Bootstrap.sh new file mode 100755 index 0000000..fddc0f7 --- /dev/null +++ b/Bootstrap.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Install nixos to specified drive. To be run from Live ISO. +# Usage: ./Bootstrap.sh [HOST] +target="${1}" +host="${2}" + +if [[ "${target}" = "" ]]; then + printf "Usage: bootstrap_nixos [HOST]\n" + return 2 +fi + +# Create partitions. +parted -s "${target}" mktable gpt +parted -s "${target}" mkpart primary 0% 512MB +parted -s "${target}" mkpart primary 512MB 100% +parted -s "${target}" name 1 NIXBOOT +parted -s "${target}" name 2 NIXROOT +parted -s "${target}" set 1 esp on + +# Format. +mkfs.fat -F 32 /dev/disk/by-partlabel/NIXBOOT +mkfs.ext4 -F /dev/disk/by-partlabel/NIXROOT + +# Mount. +mount /dev/disk/by-partlabel/NIXROOT /mnt +mkdir /mnt/boot +mount /dev/disk/by-partlabel/NIXBOOT /mnt/boot + +# Generate config. +nixos-generate-config --root /mnt + +# Install. +cd /mnt +if [[ "${host}" = "" ]]; then + printf "Warning: Installing basic system.\n" + nixos-install +else + printf "Installing ${host}...\n" + nixos-install --no-root-password --no-channel-copy --flake "${_nix_system_config}#${host}" +fi diff --git a/Makefile b/Makefile index 8f684b3..c705629 100644 --- a/Makefile +++ b/Makefile @@ -1,44 +1,53 @@ options = --option eval-cache false --fallback flake = . -.PHONY: boot -boot: - nixos-rebuild boot $(options) --flake $(flake) - -.PHONY: reboot -reboot: boot - reboot - -.PHONY: switch -switch: - nixos-rebuild switch $(options) --flake $(flake) - -.PHONY: update -update: - nix flake update - -.PHONY: live -live: - nix build -o live $(options) $(flake)#nixosConfigurations.live.config.system.build.isoImage - -.PHONY: android android: nix-on-droid switch --flake $(flake) cp ~/.termux/_font.ttf ~/.termux/font.ttf cp ~/.termux/_colors.properties ~/.termux/colors.properties -.PHONY: check +boot: + nixos-rebuild boot $(options) --flake $(flake) + +boot-vanilla: + mv /etc/nix/nix.conf /etc/nix/nix.conf_ + nixos-rebuild boot $(options) --flake $(flake) + mv /etc/nix/nix.conf_ /etc/nix/nix.conf + check: nix flake check -.PHONY: trace -trace: - nix flake check --show-trace +# HACK: https://github.com/nix-community/home-manager/issues/5589 +fix-hm-root: + mv /etc/nix/nix.conf /etc/nix/nix.conf_ + systemctl restart home-manager-root.service + mv /etc/nix/nix.conf_ /etc/nix/nix.conf + +install-nix: + sh <(curl -L https://nixos.org/nix/install) --no-daemon + +install-hm: + nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager + nix-channel --update + nix-shell '' -A install + +live: + nix build -o live $(options) $(flake)#nixosConfigurations.live.config.system.build.isoImage + +reboot: boot + reboot -.PHONY: show show: nix flake show -.PHONY: verify +switch: + nixos-rebuild switch $(options) --flake $(flake) + +trace: + nix flake check --show-trace + +update: + nix flake update + verify: git verify-commit HEAD diff --git a/config/Wallpaper.nix b/config/Wallpaper.nix index 98f63c9..5949aa3 100644 --- a/config/Wallpaper.nix +++ b/config/Wallpaper.nix @@ -1,6 +1,6 @@ { pkgs, lib, ... }: with lib; let - url = "https://i.imgur.com/GTrVpFh.jpeg"; - sha256 = "1nn3ns14py4hf6ya50a84g0za4civd6mzg86a4z4k79sf7m23wza"; + url = "https://i.imgur.com/4lqm0AZ.jpeg"; + sha256 = "1bkc2rm1jy0bva9z78rq9a5gchwa61ns1gn59kdp1k63brawhx62"; forceContrastText = false; in { options = { diff --git a/home/config/tmux/module/Config.nix b/home/config/tmux/module/Config.nix index 8d95d65..0bfdf17 100644 --- a/home/config/tmux/module/Config.nix +++ b/home/config/tmux/module/Config.nix @@ -3,6 +3,6 @@ in { text = '' unbind-key C-b - bind -n ${mod}-r source-file /etc/tmux.conf + bind -n ${mod}-r source-file ~/.config/tmux/tmux.conf ''; } diff --git a/home/program/bash/module/Bootstrap.nix b/home/program/bash/module/Bootstrap.nix deleted file mode 100644 index f082712..0000000 --- a/home/program/bash/module/Bootstrap.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ ... }: { - text = '' - # Install nixos to specified drive. To be run from Live ISO. - # Usage: bootstrap_nixos [HOST] - function bootstrap_nixos() { - local target="''${1}" - local host="''${2}" - - if [[ "''${target}" = "" ]]; then - help bootstrap_nixos - return 2 - fi - - # Create partitions. - parted -s "''${target}" mktable gpt - parted -s "''${target}" mkpart primary 0% 512MB - parted -s "''${target}" mkpart primary 512MB 100% - parted -s "''${target}" name 1 NIXBOOT - parted -s "''${target}" name 2 NIXROOT - parted -s "''${target}" set 1 esp on - - # Format. - mkfs.fat -F 32 /dev/disk/by-partlabel/NIXBOOT - mkfs.ext4 -F /dev/disk/by-partlabel/NIXROOT - - # Mount. - mount /dev/disk/by-partlabel/NIXROOT /mnt - mkdir /mnt/boot - mount /dev/disk/by-partlabel/NIXBOOT /mnt/boot - - # Generate config. - nixos-generate-config --root /mnt - - # Install. - cd /mnt - if [[ "''${host}" = "" ]]; then - _warn "Warning: Installing basic system." - nixos-install - else - _info "Installing ''${host}..." - nixos-install --no-root-password --no-channel-copy --flake "''${_nix_system_config}#''${host}" - fi - } - ''; -}