added script to install nixos with one command

This commit is contained in:
foglar 2025-01-01 19:28:16 +01:00
parent 9e4b796451
commit 8b28196951
3 changed files with 59 additions and 1 deletions

View File

@ -111,7 +111,18 @@
allowUnfree = true;
};
};
# Systems that can run tests:
supportedSystems = ["aarch64-linux" "i686-linux" "x86_64-linux"];
# Function to generate a set based on supported systems:
forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems;
# Attribute set of nixpkgs for each system:
nixpkgsFor =
forAllSystems (system: import inputs.nixpkgs {inherit system;});
in {
# NixOS Configurations
nixosConfigurations = {
kogami = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
@ -141,6 +152,7 @@
];
};
};
# Phone Configurations
nixOnDroidConfigurations = {
tsunemori = inputs.nix-on-droid.lib.nixOnDroidConfiguration {
pkgs = import inputs.nixpkgs-droid {system = "aarch64-linux";};
@ -153,5 +165,27 @@
};
};
};
# Install script
packages = forAllSystems (system: let
pkgs = nixpkgsFor.${system};
in {
default = self.packages.${system}.install;
install = pkgs.writeShellApplication {
name = "install";
runtimeInputs = with pkgs; [git busybox gum ];
text = ''${./install.sh} "$@"'';
};
});
apps = forAllSystems (system: {
default = self.apps.${system}.install;
install = {
type = "app";
program = "${self.packages.${system}.install}/bin/install";
};
});
};
}

View File

@ -26,7 +26,7 @@
boot.loader.systemd-boot.enable = true;
sys = {
audio.enable = true;
bootloader.systemd-boot.enable = true;
#bootloader.systemd-boot.enable = true;
desktop = {
plasma.enable = false;
gnome.enable = true;

24
install.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/sh
if [ $# -gt 0 ]; then
SCRIPT_DIR=$1
else
SCRIPT_DIR=~/.dotfiles
fi
nix-shell -p git --command "git clone https://git.foglar.tech/foglar/dotfiles.git $SCRIPT_DIR"
sudo nixos-generate-config --show-hardware-config >$SCRIPT_DIR/kogami/hardware-configuration.nix
sudo nixos-generate-config --show-hardware-config >$SCRIPT_DIR/ginoza/hardware-configuration.nix
sed -i "0,/shinya/s//$(whoami)/" $SCRIPT_DIR/flake.nix
if [ -z $EDITOR ]; then
EDITOR=nano
fi
$EDITOR $SCRIPT_DIR/flake.nix
profile=$(gum choose kogami ginoza)
sudo nixos-rebuild build --flake $SCRIPT_DIR#"${profile}" --update
gum confirm "Do you want to switch to the new configuration?" && sudo nixos-rebuild switch --flake $SCRIPT_DIR#"${profile}"
gum confirm "Do you want to reboot now?" && sudo reboot