mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-05 15:00:14 +00:00
move all files to new nixfmt rfc
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
{ pkgs, ... }: rec {
|
||||
{ pkgs, ... }:
|
||||
rec {
|
||||
|
||||
# Show quick helper
|
||||
default = import ./help.nix { inherit pkgs; };
|
||||
@ -30,5 +31,4 @@
|
||||
# Run neovim as an app
|
||||
neovim = import ./neovim.nix { inherit pkgs; };
|
||||
nvim = neovim;
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
# nix run github:nmasur/dotfiles#encrypt-secret > private/mysecret.age
|
||||
|
||||
type = "app";
|
||||
|
||||
program = builtins.toString (pkgs.writeShellScript "encrypt-secret" ''
|
||||
printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2
|
||||
read -p "Secret: " secret
|
||||
printf "\nEncrypting...\n\n" 1>&2
|
||||
tmpfile=$(mktemp)
|
||||
echo "''${secret}" > ''${tmpfile}
|
||||
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${
|
||||
builtins.toString ../misc/public-keys
|
||||
} $tmpfile
|
||||
rm $tmpfile
|
||||
'');
|
||||
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "encrypt-secret" ''
|
||||
printf "\nEnter the secret data to encrypt for all hosts...\n\n" 1>&2
|
||||
read -p "Secret: " secret
|
||||
printf "\nEncrypting...\n\n" 1>&2
|
||||
tmpfile=$(mktemp)
|
||||
echo "''${secret}" > ''${tmpfile}
|
||||
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${builtins.toString ../misc/public-keys} $tmpfile
|
||||
rm $tmpfile
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,39 +1,41 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
# This script will partition and format drives; use at your own risk!
|
||||
|
||||
type = "app";
|
||||
|
||||
program = builtins.toString (pkgs.writeShellScript "format-root" ''
|
||||
set -e
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "format-root" ''
|
||||
set -e
|
||||
|
||||
DISK=$1
|
||||
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
|
||||
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 disk \""/dev/''${DISK}"\"
|
||||
${pkgs.disko-packaged}/bin/disko \
|
||||
--mode create \
|
||||
--dry-run \
|
||||
--flake "path:$(pwd)#root" \
|
||||
--arg disk \""/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.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 disk "/dev/''${DISK}"
|
||||
|
||||
'');
|
||||
${pkgs.disko-packaged}/bin/disko \
|
||||
--mode create \
|
||||
--flake "path:$(pwd)#root" \
|
||||
--arg disk "/dev/''${DISK}"
|
||||
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,23 +1,25 @@
|
||||
{ pkgs, ... }: {
|
||||
{ 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 ""
|
||||
'');
|
||||
|
||||
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 ""
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,48 +1,50 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
# Inspired by https://github.com/cleverca22/nix-tests/blob/master/kexec/justdoit.nix
|
||||
# This script will partition and format drives; use at your own risk!
|
||||
|
||||
type = "app";
|
||||
|
||||
program = builtins.toString (pkgs.writeShellScript "installer" ''
|
||||
set -e
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "installer" ''
|
||||
set -e
|
||||
|
||||
DISK=$1
|
||||
FLAKE=$2
|
||||
PARTITION_PREFIX=""
|
||||
DISK=$1
|
||||
FLAKE=$2
|
||||
PARTITION_PREFIX=""
|
||||
|
||||
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
|
||||
${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \
|
||||
--foreground "#fb4934" \
|
||||
"Missing required parameter." \
|
||||
"Usage: installer -- <disk> <host>" \
|
||||
"Example: installer -- nvme0n1 tempest" \
|
||||
"Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest"
|
||||
echo "(exiting)"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$DISK" ] || [ -z "$FLAKE" ]; then
|
||||
${pkgs.gum}/bin/gum style --width 50 --margin "1 2" --padding "2 4" \
|
||||
--foreground "#fb4934" \
|
||||
"Missing required parameter." \
|
||||
"Usage: installer -- <disk> <host>" \
|
||||
"Example: installer -- nvme0n1 tempest" \
|
||||
"Flake example: nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest"
|
||||
echo "(exiting)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$DISK" in nvme*)
|
||||
PARTITION_PREFIX="p"
|
||||
esac
|
||||
case "$DISK" in nvme*)
|
||||
PARTITION_PREFIX="p"
|
||||
esac
|
||||
|
||||
${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.gum}/bin/gum confirm \
|
||||
"This will ERASE ALL DATA on the disk /dev/''${DISK}. Are you sure you want to continue?" \
|
||||
--default=false
|
||||
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100%
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on
|
||||
mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1
|
||||
mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- mklabel gpt
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart primary 512MiB 100%
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- mkpart ESP fat32 1MiB 512MiB
|
||||
${pkgs.parted}/bin/parted /dev/''${DISK} -- set 3 esp on
|
||||
mkfs.ext4 -L nixos /dev/''${DISK}''${PARTITION_PREFIX}1
|
||||
mkfs.fat -F 32 -n boot /dev/''${DISK}''${PARTITION_PREFIX}2
|
||||
|
||||
mount /dev/disk/by-label/nixos /mnt
|
||||
mkdir --parents /mnt/boot
|
||||
mount /dev/disk/by-label/boot /mnt/boot
|
||||
|
||||
${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
|
||||
'');
|
||||
mount /dev/disk/by-label/nixos /mnt
|
||||
mkdir --parents /mnt/boot
|
||||
mount /dev/disk/by-label/boot /mnt/boot
|
||||
|
||||
${pkgs.nixos-install-tools}/bin/nixos-install --flake github:nmasur/dotfiles#''${FLAKE}
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
type = "app";
|
||||
|
||||
program = builtins.toString (pkgs.writeShellScript "loadkey" ''
|
||||
printf "\nEnter the seed phrase for your SSH key...\n"
|
||||
printf "\nThen press ^D when complete.\n\n"
|
||||
mkdir -p ~/.ssh/
|
||||
${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519
|
||||
printf "\n\nContinuing activation.\n\n"
|
||||
'');
|
||||
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "loadkey" ''
|
||||
printf "\nEnter the seed phrase for your SSH key...\n"
|
||||
printf "\nThen press ^D when complete.\n\n"
|
||||
mkdir -p ~/.ssh/
|
||||
${pkgs.melt}/bin/melt restore ~/.ssh/id_ed25519
|
||||
printf "\n\nContinuing activation.\n\n"
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
type = "app";
|
||||
|
||||
program = "${
|
||||
(import ../modules/common/neovim/package {
|
||||
inherit pkgs;
|
||||
colors = (import ../colorscheme/nord).dark;
|
||||
})
|
||||
}/bin/nvim";
|
||||
|
||||
(import ../modules/common/neovim/package {
|
||||
inherit pkgs;
|
||||
colors = (import ../colorscheme/nord).dark;
|
||||
})
|
||||
}/bin/nvim";
|
||||
}
|
||||
|
@ -1,19 +1,21 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
type = "app";
|
||||
|
||||
program = builtins.toString (pkgs.writeShellScript "netdata-cloud" ''
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
mkdir --parents --mode 0750 /var/lib/netdata/cloud.d
|
||||
printf "\nEnter the claim token for netdata cloud...\n\n"
|
||||
read -p "Token: " token
|
||||
echo "''${token}" > /var/lib/netdata/cloud.d/token
|
||||
chown -R netdata:netdata /var/lib/netdata
|
||||
${pkgs.netdata}/bin/netdata-claim.sh -id=$(uuidgen)
|
||||
printf "\n\nNow restart netdata service.\n\n"
|
||||
'');
|
||||
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "netdata-cloud" ''
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
mkdir --parents --mode 0750 /var/lib/netdata/cloud.d
|
||||
printf "\nEnter the claim token for netdata cloud...\n\n"
|
||||
read -p "Token: " token
|
||||
echo "''${token}" > /var/lib/netdata/cloud.d/token
|
||||
chown -R netdata:netdata /var/lib/netdata
|
||||
${pkgs.netdata}/bin/netdata-claim.sh -id=$(uuidgen)
|
||||
printf "\n\nNow restart netdata service.\n\n"
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
type = "app";
|
||||
|
||||
program = builtins.toString (pkgs.writeShellScript "readme" ''
|
||||
${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md}
|
||||
'');
|
||||
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "readme" ''
|
||||
${pkgs.glow}/bin/glow --pager ${builtins.toString ../README.md}
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
{ pkgs, ... }: {
|
||||
{ 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
|
||||
sudo darwin-rebuild switch --flake ${builtins.toString ../.}
|
||||
else
|
||||
doas nixos-rebuild switch --flake ${builtins.toString ../.}
|
||||
fi
|
||||
'');
|
||||
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "rebuild" ''
|
||||
echo ${pkgs.system}
|
||||
SYSTEM=${if pkgs.stdenv.isDarwin then "darwin" else "linux"}
|
||||
if [ "$SYSTEM" == "darwin" ]; then
|
||||
sudo darwin-rebuild switch --flake ${builtins.toString ../.}
|
||||
else
|
||||
doas nixos-rebuild switch --flake ${builtins.toString ../.}
|
||||
fi
|
||||
''
|
||||
);
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
||||
# nix run github:nmasur/dotfiles#reencrypt-secrets ./private
|
||||
|
||||
type = "app";
|
||||
|
||||
program = builtins.toString (pkgs.writeShellScript "reencrypt-secrets" ''
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Must provide directory to reencrypt."
|
||||
exit 1
|
||||
fi
|
||||
encrypted=$1
|
||||
for encryptedfile in ''${1}/*; do
|
||||
tmpfile=$(mktemp)
|
||||
echo "Decrypting ''${encryptedfile}..."
|
||||
${pkgs.age}/bin/age --decrypt \
|
||||
--identity ~/.ssh/id_ed25519 $encryptedfile > $tmpfile
|
||||
echo "Encrypting ''${encryptedfile}..."
|
||||
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${
|
||||
builtins.toString ../misc/public-keys
|
||||
} $tmpfile > $encryptedfile
|
||||
rm $tmpfile
|
||||
done
|
||||
echo "Finished."
|
||||
'');
|
||||
|
||||
program = builtins.toString (
|
||||
pkgs.writeShellScript "reencrypt-secrets" ''
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Must provide directory to reencrypt."
|
||||
exit 1
|
||||
fi
|
||||
encrypted=$1
|
||||
for encryptedfile in ''${1}/*; do
|
||||
tmpfile=$(mktemp)
|
||||
echo "Decrypting ''${encryptedfile}..."
|
||||
${pkgs.age}/bin/age --decrypt \
|
||||
--identity ~/.ssh/id_ed25519 $encryptedfile > $tmpfile
|
||||
echo "Encrypting ''${encryptedfile}..."
|
||||
${pkgs.age}/bin/age --encrypt --armor --recipients-file ${builtins.toString ../misc/public-keys} $tmpfile > $encryptedfile
|
||||
rm $tmpfile
|
||||
done
|
||||
echo "Finished."
|
||||
''
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user