update installer

This commit is contained in:
Dmitriy Holkin 2020-08-04 03:17:47 +04:00
parent d8d9988453
commit de91841c0e
6 changed files with 62 additions and 35 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake || use nix

View File

@ -60,19 +60,19 @@
};
in genAttrs hosts mkHost;
legacyPackages.x86_64-linux =
(builtins.head (builtins.attrValues self.nixosConfigurations)).pkgs;
# legacyPackages.x86_64-linux =
# (builtins.head (builtins.attrValues self.nixosConfigurations)).pkgs;
# nix run github:serokell/deploy
# Because sudo requires local presence of my Yubikey, we have to manually activate the system
# sudo nix-env -p /nix/var/nix/profiles/system --set /nix/var/nix/profiles/per-user/alukard/system;
# sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
deploy = {
user = "alukard";
nodes = builtins.mapAttrs (_: conf: {
hostname = conf.config.networking.hostName;
profiles.system.path = conf.config.system.build.toplevel;
}) self.nixosConfigurations;
};
# deploy = {
# user = "alukard";
# nodes = builtins.mapAttrs (_: conf: {
# hostname = conf.config.networking.hostName;
# profiles.system.path = conf.config.system.build.toplevel;
# }) self.nixosConfigurations;
# };
};
}

17
install/install.sh Executable file → Normal file
View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p git
cd ..
CONFIG_FOLDER=$(pwd)
cd install
@ -40,13 +41,11 @@ mkswap -L swap $SWAP_PARTITION
# Generate config (hardware)
nixos-generate-config --root /mnt/
cp /mnt/etc/nixos/hardware-configuration.nix $CONFIG_FOLDER/hardware-configuration/$DEVICE_NAME.nix
echo "import $CONFIG_FOLDER \"$DEVICE_NAME\"" > /mnt/etc/nixos/configuration.nix
sed -i 's#nixos-config=/etc/nixos/#nixos-config=/mnt/etc/nixos/#' $CONFIG_FOLDER/modules/packages.nix
read -p "Please, add swap device into nixos-config/modules/filesystems.nix before continue"
nixos-install -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/ae6bdcc53584aaf20211ce1814bea97ece08a248.tar.gz --max-jobs $MAX_JOBS --no-root-passwd
read -p "Press enter to continue"
sed -i 's#nixos-config=/mnt/etc/nixos/#nixos-config=/etc/nixos/#' $CONFIG_FOLDER/modules/packages.nix
sed -i 's#<nixpkgs/nixos/modules/installer/scan/not-detected.nix>#"${inputs.nixpkgs}/nixos/modules/installer/scan/not-detected.nix"#' $CONFIG_FOLDER/hardware-configuration/$DEVICE_NAME.nix
cp ./min-config.nix /mnt/etc/nixos/configuration.nix
nixos-install -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/840c782d507d60aaa49aa9e3f6d0b0e780912742.tar.gz --max-jobs $MAX_JOBS --no-root-passwd
mkdir -p /mnt/home/alukard/nixos-config
cp -aT $CONFIG_FOLDER /mnt/home/alukard/nixos-config
echo "import /home/alukard/nixos-config \"$DEVICE_NAME\"" > /mnt/etc/nixos/configuration.nix
echo "Installation complete!"
echo "Installation complete!"

View File

@ -10,21 +10,6 @@
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
fileSystems = {
"/" = {
options = [ "noatime" "ssd" "compress=zstd" ];
};
"/.snapshots" = {
options = [ "noatime" "ssd" "compress=zstd" ];
};
"/home" = {
options = [ "noatime" "ssd" "compress=zstd" ];
};
"/nix-store" = {
options = [ "noatime" "ssd" "compress=zstd" ];
};
};
networking = {
hostName = "nixos";
firewall.enable = false;
@ -57,7 +42,7 @@
time.timeZone = "Europe/Volgograd";
environment.systemPackages = with pkgs; [
wget vim git
wget vim git gnupg
];
users.mutableUsers = false;
@ -68,6 +53,6 @@
hashedPassword = "$6$kDBGyd99tto$9LjQwixa7NYB9Kaey002MD94zHob1MmNbVz9kx3yX6Q4AmVgsFMGUyNuHozXprxyuXHIbOlTcf8nd4rK8MWfI/";
};
system.stateVersion = "19.03";
system.stateVersion = "20.03";
}

11
install/shell.nix Normal file
View File

@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
name = "nixflk";
nativeBuildInputs = with pkgs; [
git
];
shellHook = ''
'';
}

31
shell.nix Normal file
View File

@ -0,0 +1,31 @@
{ pkgs ? import <nixpkgs> { } }:
let
configs = "${toString ./.}#nixosConfigurations";
build = "config.system.build";
rebuild = pkgs.writeShellScriptBin "rebuild" ''
if [[ -z $1 ]]; then
echo "Usage: $(basename $0) host {switch|boot|test}"
else
sudo -E nix shell -vv ${configs}.$1.${build}.toplevel -c switch-to-configuration $2
fi
'';
in
pkgs.mkShell {
name = "nixflk";
nativeBuildInputs = with pkgs; [
git
git-crypt
nixFlakes
rebuild
gnupg
];
shellHook = ''
PATH=${
pkgs.writeShellScriptBin "nix" ''
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"
''
}/bin:$PATH
'';
}