mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 09:55:37 +00:00
refactor apps and separate disko disks
format-root app still not working
This commit is contained in:
parent
3fe6911e2d
commit
cb60542980
@ -1,45 +1,19 @@
|
|||||||
{ pkgs, ... }: rec {
|
{ pkgs, ... }: rec {
|
||||||
|
|
||||||
default = {
|
# Show quick helper
|
||||||
type = "app";
|
default = import ./help.nix { inherit pkgs; };
|
||||||
program = builtins.toString (pkgs.writeShellScript "default" ''
|
|
||||||
${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options"
|
|
||||||
${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.'
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
${pkgs.gum}/bin/gum format --type=template -- \
|
|
||||||
' • {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \
|
|
||||||
' • {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \
|
|
||||||
' • {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \
|
|
||||||
' • {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \
|
|
||||||
' • {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \
|
|
||||||
' • {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \
|
|
||||||
' • {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \
|
|
||||||
' • {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}'
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
'');
|
|
||||||
};
|
|
||||||
|
|
||||||
# Format and install from nothing
|
# Format primary disk
|
||||||
|
format-root = import ./format-root.nix { inherit pkgs; };
|
||||||
|
|
||||||
|
# Format and install from nothing (deprecated)
|
||||||
installer = import ./installer.nix { inherit pkgs; };
|
installer = import ./installer.nix { inherit pkgs; };
|
||||||
|
|
||||||
# Display the readme for this repository
|
# Display the readme for this repository
|
||||||
readme = import ./readme.nix { inherit pkgs; };
|
readme = import ./readme.nix { inherit pkgs; };
|
||||||
|
|
||||||
# Rebuild
|
# Rebuild
|
||||||
rebuild = {
|
rebuild = import ./rebuild.nix { inherit pkgs; };
|
||||||
type = "app";
|
|
||||||
program = builtins.toString (pkgs.writeShellScript "rebuild" ''
|
|
||||||
echo ${pkgs.system}
|
|
||||||
SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"}
|
|
||||||
if [ "$SYSTEM" == "darwin" ]; then
|
|
||||||
darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass
|
|
||||||
else
|
|
||||||
nixos-rebuild switch --flake github:nmasur/dotfiles
|
|
||||||
fi
|
|
||||||
'');
|
|
||||||
};
|
|
||||||
|
|
||||||
# Load the SSH key for this machine
|
# Load the SSH key for this machine
|
||||||
loadkey = import ./loadkey.nix { inherit pkgs; };
|
loadkey = import ./loadkey.nix { inherit pkgs; };
|
||||||
@ -54,17 +28,7 @@
|
|||||||
netdata = import ./netdata-cloud.nix { inherit pkgs; };
|
netdata = import ./netdata-cloud.nix { inherit pkgs; };
|
||||||
|
|
||||||
# Run neovim as an app
|
# Run neovim as an app
|
||||||
neovim = {
|
neovim = import ./neovim.nix { inherit pkgs; };
|
||||||
type = "app";
|
|
||||||
program = "${
|
|
||||||
(import ../modules/common/neovim/package {
|
|
||||||
inherit pkgs;
|
|
||||||
colors =
|
|
||||||
import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
|
|
||||||
})
|
|
||||||
}/bin/nvim";
|
|
||||||
};
|
|
||||||
|
|
||||||
nvim = neovim;
|
nvim = neovim;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
39
apps/format-root.nix
Normal file
39
apps/format-root.nix
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
|
||||||
|
# This script will partition and format drives; use at your own risk!
|
||||||
|
|
||||||
|
type = "app";
|
||||||
|
|
||||||
|
program = builtins.toString (pkgs.writeShellScript "format-root" ''
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DISK=$1
|
||||||
|
|
||||||
|
if [ -z "''${DISK}" ]; then
|
||||||
|
${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \
|
||||||
|
--foreground "#fb4934" \
|
||||||
|
"Missing required parameter." \
|
||||||
|
"Usage: format-root -- <disk>" \
|
||||||
|
"Flake example: nix run github:nmasur/dotfiles#format-root -- nvme0n1"
|
||||||
|
echo "(exiting)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
${pkgs.disko-packaged}/bin/disko \
|
||||||
|
--mode create \
|
||||||
|
--dry-run \
|
||||||
|
--flake "path:$(pwd)#root" \
|
||||||
|
--arg disks '[ "/dev/$DISK" ]'
|
||||||
|
|
||||||
|
${pkgs.gum}/bin/gum confirm \
|
||||||
|
"This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \
|
||||||
|
--default=false
|
||||||
|
|
||||||
|
${pkgs.disko-packaged}/bin/disko \
|
||||||
|
--mode create \
|
||||||
|
--flake "path:$(pwd)#root" \
|
||||||
|
--arg disks '[ '"/dev/$DISK"' ]'
|
||||||
|
|
||||||
|
'');
|
||||||
|
|
||||||
|
}
|
23
apps/help.nix
Normal file
23
apps/help.nix
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
|
||||||
|
type = "app";
|
||||||
|
|
||||||
|
program = builtins.toString (pkgs.writeShellScript "default" ''
|
||||||
|
${pkgs.gum}/bin/gum style --margin "1 2" --padding "0 2" --foreground "15" --background "55" "Options"
|
||||||
|
${pkgs.gum}/bin/gum format --type=template -- ' {{ Italic "Run with" }} {{ Color "15" "69" " nix run github:nmasur/dotfiles#" }}{{ Color "15" "62" "someoption" }}{{ Color "15" "69" " " }}.'
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
${pkgs.gum}/bin/gum format --type=template -- \
|
||||||
|
' • {{ Color "15" "57" " readme " }} {{ Italic "Documentation for this repository." }}' \
|
||||||
|
' • {{ Color "15" "57" " rebuild " }} {{ Italic "Switch to this configuration." }}' \
|
||||||
|
' • {{ Color "15" "57" " installer " }} {{ Italic "Format and install from nothing." }}' \
|
||||||
|
' • {{ Color "15" "57" " neovim " }} {{ Italic "Test out the Neovim package." }}' \
|
||||||
|
' • {{ Color "15" "57" " loadkey " }} {{ Italic "Load an ssh key for this machine using melt." }}' \
|
||||||
|
' • {{ Color "15" "57" " encrypt-secret " }} {{ Italic "Encrypt a secret for all machines." }}' \
|
||||||
|
' • {{ Color "15" "57" " reencrypt-secrets " }} {{ Italic "Reencrypt all secrets when new machine is added." }}' \
|
||||||
|
' • {{ Color "15" "57" " netdata " }} {{ Italic "Connect a machine to Netdata cloud." }}'
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
'');
|
||||||
|
|
||||||
|
}
|
13
apps/neovim.nix
Normal file
13
apps/neovim.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
|
||||||
|
type = "app";
|
||||||
|
|
||||||
|
program = "${
|
||||||
|
(import ../modules/common/neovim/package {
|
||||||
|
inherit pkgs;
|
||||||
|
colors =
|
||||||
|
import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
|
||||||
|
})
|
||||||
|
}/bin/nvim";
|
||||||
|
|
||||||
|
}
|
15
apps/rebuild.nix
Normal file
15
apps/rebuild.nix
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
|
||||||
|
type = "app";
|
||||||
|
|
||||||
|
program = builtins.toString (pkgs.writeShellScript "rebuild" ''
|
||||||
|
echo ${pkgs.system}
|
||||||
|
SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"}
|
||||||
|
if [ "$SYSTEM" == "darwin" ]; then
|
||||||
|
darwin-rebuild switch --flake github:nmasur/dotfiles#lookingglass
|
||||||
|
else
|
||||||
|
nixos-rebuild switch --flake github:nmasur/dotfiles
|
||||||
|
fi
|
||||||
|
'');
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{ disks, ... }: {
|
{ disks ? [ ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
boot = {
|
boot = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
16
flake.nix
16
flake.nix
@ -152,10 +152,8 @@
|
|||||||
darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home;
|
darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home;
|
||||||
};
|
};
|
||||||
|
|
||||||
diskoConfigurations = {
|
# Disk formatting
|
||||||
root = import ./disks/root.nix;
|
diskoConfigurations = { root = import ./disks/root.nix; };
|
||||||
swan = { ... }: (import ./hosts/swan/disks.nix { }).disko.devices;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Package servers into images with a generator
|
# Package servers into images with a generator
|
||||||
packages = forAllSystems (system: {
|
packages = forAllSystems (system: {
|
||||||
@ -181,7 +179,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
apps = forAllSystems (system:
|
apps = forAllSystems (system:
|
||||||
let pkgs = import nixpkgs { inherit system overlays; };
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = overlays ++ [
|
||||||
|
(final: prev: {
|
||||||
|
disko-packaged = inputs.disko.packages.${system}.disko;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
in import ./apps { inherit pkgs; });
|
in import ./apps { inherit pkgs; });
|
||||||
|
|
||||||
devShells = forAllSystems (system:
|
devShells = forAllSystems (system:
|
||||||
|
@ -10,7 +10,6 @@ nixpkgs.lib.nixosSystem {
|
|||||||
specialArgs = { };
|
specialArgs = { };
|
||||||
modules = [
|
modules = [
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./disks.nix
|
|
||||||
../../modules/common
|
../../modules/common
|
||||||
../../modules/nixos
|
../../modules/nixos
|
||||||
(removeAttrs globals [ "mail.server" ])
|
(removeAttrs globals [ "mail.server" ])
|
||||||
@ -21,6 +20,12 @@ nixpkgs.lib.nixosSystem {
|
|||||||
server = true;
|
server = true;
|
||||||
zfs.enable = true;
|
zfs.enable = true;
|
||||||
|
|
||||||
|
disko = {
|
||||||
|
enableConfig = true;
|
||||||
|
devices.disks =
|
||||||
|
import ../../disks/root.nix { disks = [ "/dev/nvme0n1" ]; };
|
||||||
|
};
|
||||||
|
|
||||||
# head -c 8 /etc/machine-id
|
# head -c 8 /etc/machine-id
|
||||||
networking.hostId = "600279f4"; # Random ID required for ZFS
|
networking.hostId = "600279f4"; # Random ID required for ZFS
|
||||||
|
|
||||||
|
@ -12,15 +12,15 @@
|
|||||||
boot.kernelModules = [ "kvm-intel" ];
|
boot.kernelModules = [ "kvm-intel" ];
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
fileSystems."/" = {
|
# fileSystems."/" = {
|
||||||
device = "/dev/disk/by-label/nixos";
|
# device = "/dev/disk/by-label/nixos";
|
||||||
fsType = "ext4";
|
# fsType = "ext4";
|
||||||
};
|
# };
|
||||||
|
#
|
||||||
fileSystems."/boot" = {
|
# fileSystems."/boot" = {
|
||||||
device = "/dev/disk/by-label/boot";
|
# device = "/dev/disk/by-label/boot";
|
||||||
fsType = "vfat";
|
# fsType = "vfat";
|
||||||
};
|
# };
|
||||||
|
|
||||||
swapDevices = [ ];
|
swapDevices = [ ];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user