mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-05 15:00:14 +00:00
refactor apps and separate disko disks
format-root app still not working
This commit is contained in:
@ -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
|
||||
'');
|
||||
|
||||
}
|
Reference in New Issue
Block a user