mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 04:05:38 +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 {
|
||||
|
||||
default = {
|
||||
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 ""
|
||||
'');
|
||||
};
|
||||
# Show quick helper
|
||||
default = import ./help.nix { inherit pkgs; };
|
||||
|
||||
# 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; };
|
||||
|
||||
# Display the readme for this repository
|
||||
readme = import ./readme.nix { inherit pkgs; };
|
||||
|
||||
# Rebuild
|
||||
rebuild = {
|
||||
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
|
||||
'');
|
||||
};
|
||||
rebuild = import ./rebuild.nix { inherit pkgs; };
|
||||
|
||||
# Load the SSH key for this machine
|
||||
loadkey = import ./loadkey.nix { inherit pkgs; };
|
||||
@ -54,17 +28,7 @@
|
||||
netdata = import ./netdata-cloud.nix { inherit pkgs; };
|
||||
|
||||
# Run neovim as an app
|
||||
neovim = {
|
||||
type = "app";
|
||||
program = "${
|
||||
(import ../modules/common/neovim/package {
|
||||
inherit pkgs;
|
||||
colors =
|
||||
import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
|
||||
})
|
||||
}/bin/nvim";
|
||||
};
|
||||
|
||||
neovim = import ./neovim.nix { inherit pkgs; };
|
||||
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 = {
|
||||
boot = {
|
||||
type = "disk";
|
||||
|
16
flake.nix
16
flake.nix
@ -152,10 +152,8 @@
|
||||
darwinConfigurations.lookingglass.config.home-manager.users."Noah.Masur".home;
|
||||
};
|
||||
|
||||
diskoConfigurations = {
|
||||
root = import ./disks/root.nix;
|
||||
swan = { ... }: (import ./hosts/swan/disks.nix { }).disko.devices;
|
||||
};
|
||||
# Disk formatting
|
||||
diskoConfigurations = { root = import ./disks/root.nix; };
|
||||
|
||||
# Package servers into images with a generator
|
||||
packages = forAllSystems (system: {
|
||||
@ -181,7 +179,15 @@
|
||||
});
|
||||
|
||||
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; });
|
||||
|
||||
devShells = forAllSystems (system:
|
||||
|
@ -10,7 +10,6 @@ nixpkgs.lib.nixosSystem {
|
||||
specialArgs = { };
|
||||
modules = [
|
||||
./hardware-configuration.nix
|
||||
./disks.nix
|
||||
../../modules/common
|
||||
../../modules/nixos
|
||||
(removeAttrs globals [ "mail.server" ])
|
||||
@ -21,6 +20,12 @@ nixpkgs.lib.nixosSystem {
|
||||
server = true;
|
||||
zfs.enable = true;
|
||||
|
||||
disko = {
|
||||
enableConfig = true;
|
||||
devices.disks =
|
||||
import ../../disks/root.nix { disks = [ "/dev/nvme0n1" ]; };
|
||||
};
|
||||
|
||||
# head -c 8 /etc/machine-id
|
||||
networking.hostId = "600279f4"; # Random ID required for ZFS
|
||||
|
||||
|
@ -12,15 +12,15 @@
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/boot";
|
||||
fsType = "vfat";
|
||||
};
|
||||
# fileSystems."/" = {
|
||||
# device = "/dev/disk/by-label/nixos";
|
||||
# fsType = "ext4";
|
||||
# };
|
||||
#
|
||||
# fileSystems."/boot" = {
|
||||
# device = "/dev/disk/by-label/boot";
|
||||
# fsType = "vfat";
|
||||
# };
|
||||
|
||||
swapDevices = [ ];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user