Continue moving personal packages from overlays
Continue moving out of the overlay model for everything and into running sutff directly out of the packages. This should give a cleaner separation of the things that I don't need to maintain separately
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "aacs" ''
|
|
||||||
set -ex
|
|
||||||
[ ! -d "''${HOME}/.config/aacs" ] && mkdir -p "''${HOME}/.config/aacs"
|
|
||||||
cd "''${HOME}/.config/aacs"
|
|
||||||
[ -f KEYDB.cfg.zip ] && rm -f KEYDB.cfg.zip
|
|
||||||
curl -L -o KEYDB.cfg.zip "http://fvonline-db.bplaced.net/fv_download.php?lang=eng"
|
|
||||||
${pkgs.unzip}/bin/unzip KEYDB.cfg.zip
|
|
||||||
mv keydb.cfg KEYDB.cfg''
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
{ writeShellScriptBin, openssl, ... }:
|
|
||||||
|
|
||||||
writeShellScriptBin "create_ssl" ''
|
|
||||||
set -e -o pipefail
|
|
||||||
name="''${1}"
|
|
||||||
root_key="''${2}"
|
|
||||||
|
|
||||||
function usage {
|
|
||||||
echo "USAGE: create_ssl <cert name> <root path>"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "''${name}" ]; then
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "''${root_key}" ]; then
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the certificate key
|
|
||||||
${openssl}/bin/openssl ecparam -out "''${name}.key" -name prime256v1 -genkey
|
|
||||||
# Create the CSR
|
|
||||||
${openssl}/bin/openssl req -name -sha256 -key "''${name}.key" -out "''${name}.csr"
|
|
||||||
# Sign it
|
|
||||||
${openssl}/bin/openssl x509 -req -in "''${name}.csr" -CA "''${root_key}.crt" -CAkey "''${root_key}.key" -CAcreateserial -out "''${name}.crt" -days 3650 -sha256
|
|
||||||
''
|
|
||||||
@@ -40,13 +40,7 @@ rec {
|
|||||||
];
|
];
|
||||||
|
|
||||||
# My own packages
|
# My own packages
|
||||||
aacs = prev.callPackage ./aacs.nix { };
|
|
||||||
create_ssl = prev.callPackage ./create_ssl.nix { };
|
|
||||||
enwiki-dump = prev.callPackage ./enwiki-dump.nix { };
|
enwiki-dump = prev.callPackage ./enwiki-dump.nix { };
|
||||||
inject = prev.callPackage ./inject.nix { inherit (final) pkgs; };
|
|
||||||
inject-darwin = prev.callPackage ./inject-darwin.nix { inherit (final) pkgs; };
|
|
||||||
setup-ssh = prev.callPackage ./setup-ssh { pkgs = final.pkgs; };
|
|
||||||
upgrade-pg-cluster = prev.callPackage ./upgrade-pg-cluster.nix { };
|
|
||||||
|
|
||||||
# Overrides of packages
|
# Overrides of packages
|
||||||
brew = prev.callPackage ./homebrew.nix { };
|
brew = prev.callPackage ./homebrew.nix { };
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
{ pkgs
|
|
||||||
, coreutils
|
|
||||||
, curl
|
|
||||||
, gnutar
|
|
||||||
, nix
|
|
||||||
, ...
|
|
||||||
}:
|
|
||||||
pkgs.writeShellScriptBin "inject-darwin" ''
|
|
||||||
set -ex
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
dir="$(${coreutils}/bin/mktemp -d)"
|
|
||||||
cd "''${dir}"
|
|
||||||
|
|
||||||
# Install nix-darwin
|
|
||||||
${nix}/bin/nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
|
|
||||||
./result/bin/darwin-installer
|
|
||||||
|
|
||||||
# Get my configuration
|
|
||||||
mkdir -p ~/.config/darwin
|
|
||||||
cd ~/.config/darwin
|
|
||||||
${curl}/bin/curl -O -L https://github.com/greg-hellings/nixos-config/archive/refs/heads/main.tar.gz
|
|
||||||
${gnutar}/bin/tar xvzf main.tar.gz --strip-components 1
|
|
||||||
|
|
||||||
# Build NixOS for this system
|
|
||||||
pushd "''${dir}"
|
|
||||||
${nix}/bin/nix build "~/.config/darwin#darwinConfigurations.$(hostname -s).system"
|
|
||||||
./result/sw/bin/darwin-rebuild switch --flake ~/.config/darwin
|
|
||||||
popd
|
|
||||||
rm -r "''${dir}"
|
|
||||||
''
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
{ pkgs
|
|
||||||
, git
|
|
||||||
, ...
|
|
||||||
}:
|
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "inject-nixos-config" ''
|
|
||||||
hostname="''${1}"
|
|
||||||
if [ -n "''${hostname}"]; then
|
|
||||||
echo "You must provide a hostname";
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
mv /etc/nixos /etc/nixos.bk
|
|
||||||
cd /etc
|
|
||||||
${git}/bin/git clone http://github.com/greg-hellings/nixos-config nixos
|
|
||||||
mkdir -p "/etc/nixos/hosts/''${hostname}"
|
|
||||||
|
|
||||||
# Prepares everything for the flake usage
|
|
||||||
#cp /etc/nixos.bk/configuration.nix "/etc/nixos/hosts/''${hostname}/default.nix"
|
|
||||||
cat << EOF > "/etc/nixos/hosts/''${hostname}/default.nix"
|
|
||||||
{ pkgs, config, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [ ./hardware-configuration.nix ];
|
|
||||||
|
|
||||||
boot.loader = {
|
|
||||||
systemd-boot.enable = true;
|
|
||||||
efi.canTouchEfiVariables = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
networking.hostName = "''${hostname}";
|
|
||||||
greg = {
|
|
||||||
home = true;
|
|
||||||
tailscale.enable = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
cp /etc/nixos.bk/hardware-configuration.nix "/etc/nixos/hosts/''${hostname}/hardware-configuration.nix"
|
|
||||||
|
|
||||||
# Prepare home-manager portion for setup
|
|
||||||
mkdir -p "/etc/nixos/home/hosts/''${hostname}"
|
|
||||||
cat << EOF > "/etc/nixos/home/hosts/''${hostname}/default.nix"
|
|
||||||
{ pkgs, config, ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Prepares it for injecting the use case into the flake usage
|
|
||||||
cp /etc/nixos.bk/hardware-configuration.nix /etc/nixos
|
|
||||||
chown -R greg nixos
|
|
||||||
|
|
||||||
echo "Now you should be able to just run `nixos-rebuild switch` to enable the flake functionality"
|
|
||||||
echo "After that and adding the entry to the flake, run `nixos-rebuild boot --flake '.#''${hostname}'` and reboot"
|
|
||||||
''
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{ pkgs, gh, ... }:
|
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "setup-ssh" (builtins.replaceStrings [ "gh " ] [ "${gh}/bin/gh " ] (builtins.readFile ./setup-ssh.sh))
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{ postgresql_15, postgresql_16, writeScriptBin, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
newPostgres = postgresql_16;
|
|
||||||
oldPostgres = postgresql_15;
|
|
||||||
in
|
|
||||||
writeScriptBin "upgrade-pg-cluster" ''
|
|
||||||
set -eux
|
|
||||||
systemctl stop postgresql
|
|
||||||
|
|
||||||
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
|
|
||||||
export NEWBIN="${newPostgres}/bin"
|
|
||||||
|
|
||||||
export OLDDATA="/var/lib/postgresql/${oldPostgres.psqlSchema}"
|
|
||||||
export OLDBIN="${oldPostgres}/bin"
|
|
||||||
|
|
||||||
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
|
||||||
cd "$NEWDATA"
|
|
||||||
sudo -u postgres "$NEWBIN/initdb" -D "$NEWDATA"
|
|
||||||
|
|
||||||
sudo -u postgres "$NEWBIN/pg_upgrade" \
|
|
||||||
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
|
||||||
--old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
|
|
||||||
"$@"
|
|
||||||
''
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{ writeShellApplication, unzip, ... }:
|
||||||
|
|
||||||
|
writeShellApplication {
|
||||||
|
name = "aacs";
|
||||||
|
runtimeInputs = [ unzip ];
|
||||||
|
text = ''
|
||||||
|
[ ! -d "''${HOME}/.config/aacs" ] && mkdir -p "''${HOME}/.config/aacs"
|
||||||
|
cd "''${HOME}/.config/aacs"
|
||||||
|
[ -f KEYDB.cfg.zip ] && rm -f KEYDB.cfg.zip
|
||||||
|
curl -L -o KEYDB.cfg.zip "http://fvonline-db.bplaced.net/fv_download.php?lang=eng"
|
||||||
|
unzip KEYDB.cfg.zip
|
||||||
|
mv keydb.cfg KEYDB.config
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
{ writeShellApplication, openssl, ... }:
|
||||||
|
|
||||||
|
writeShellApplication {
|
||||||
|
name = "create_ssl";
|
||||||
|
runtimeInputs = [ openssl ];
|
||||||
|
text = ''
|
||||||
|
set -e -o pipefail
|
||||||
|
name="''${1}"
|
||||||
|
root_key="''${2}"
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "USAGE: create_ssl <cert name> <root path>"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "''${name}" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "''${root_key}" ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the certificate key
|
||||||
|
openssl ecparam -out "''${name}.key" -name prime256v1 -genkey
|
||||||
|
# Create the CSR
|
||||||
|
openssl req -name -sha256 -key "''${name}.key" -out "''${name}.csr"
|
||||||
|
# Sign it
|
||||||
|
openssl x509 -req -in "''${name}.csr" -CA "''${root_key}.crt" -CAkey "''${root_key}.key" -CAcreateserial -out "''${name}.crt" -days 3650 -sha256
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -8,6 +8,12 @@ in
|
|||||||
#default = iso;
|
#default = iso;
|
||||||
#iso = top.self.nixosConfigurations.iso.config.system.build.isoImage;
|
#iso = top.self.nixosConfigurations.iso.config.system.build.isoImage;
|
||||||
#iso-beta = self.nixosConfigurations.iso-beta.config.system.build.isoImage;
|
#iso-beta = self.nixosConfigurations.iso-beta.config.system.build.isoImage;
|
||||||
|
aacs = c ./aacs.nix { };
|
||||||
|
create_ssl = c ./create_ssl.nix { };
|
||||||
|
inject-darwin = c ./inject-darwin.nix { };
|
||||||
|
inject = c ./inject.nix { };
|
||||||
hms = c ./hms { };
|
hms = c ./hms { };
|
||||||
|
setup-ssh = c ./setup-ssh { };
|
||||||
|
upgrade-pg-cluster = c ./upgrade-pg-cluster.nix { };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
writeShellApplication,
|
||||||
|
coreutils,
|
||||||
|
curl,
|
||||||
|
gnutar,
|
||||||
|
nix,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "inject-darwin";
|
||||||
|
runtimeInputs = [
|
||||||
|
coreutils
|
||||||
|
curl
|
||||||
|
gnutar
|
||||||
|
nix
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
dir="$(mktemp -d)"
|
||||||
|
cd "''${dir}"
|
||||||
|
|
||||||
|
# Install nix-darwin
|
||||||
|
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
|
||||||
|
./result/bin/darwin-installer
|
||||||
|
|
||||||
|
# Get my configuration
|
||||||
|
mkdir -p ~/.config/darwin
|
||||||
|
cd ~/.config/darwin
|
||||||
|
curl -O -L https://github.com/greg-hellings/nixos-config/archive/refs/heads/main.tar.gz
|
||||||
|
tar xvzf main.tar.gz --strip-components 1
|
||||||
|
|
||||||
|
# Build NixOS for this system
|
||||||
|
pushd "''${dir}"
|
||||||
|
nix build "~/.config/darwin#darwinConfigurations.$(hostname -s).system"
|
||||||
|
./result/sw/bin/darwin-rebuild switch --flake ~/.config/darwin
|
||||||
|
popd
|
||||||
|
rm -r "''${dir}"
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
{ writeShellApplication, git, ... }:
|
||||||
|
|
||||||
|
writeShellApplication {
|
||||||
|
name = "inject-nixos-config";
|
||||||
|
runtimeInputs = [ git ];
|
||||||
|
text = ''
|
||||||
|
hostname="''${1}"
|
||||||
|
if [ -n "''${hostname}"]; then
|
||||||
|
echo "You must provide a hostname";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv /etc/nixos /etc/nixos.bk
|
||||||
|
cd /etc
|
||||||
|
git clone http://github.com/greg-hellings/nixos-config nixos
|
||||||
|
mkdir -p "/etc/nixos/hosts/''${hostname}"
|
||||||
|
|
||||||
|
# Prepares everything for the flake usage
|
||||||
|
#cp /etc/nixos.bk/configuration.nix "/etc/nixos/hosts/''${hostname}/default.nix"
|
||||||
|
cat << EOF > "/etc/nixos/hosts/''${hostname}/default.nix"
|
||||||
|
{ pkgs, config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ./hardware-configuration.nix ];
|
||||||
|
|
||||||
|
boot.loader = {
|
||||||
|
systemd-boot.enable = true;
|
||||||
|
efi.canTouchEfiVariables = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.hostName = "''${hostname}";
|
||||||
|
greg = {
|
||||||
|
home = true;
|
||||||
|
tailscale.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
cp /etc/nixos.bk/hardware-configuration.nix "/etc/nixos/hosts/''${hostname}/hardware-configuration.nix"
|
||||||
|
|
||||||
|
# Prepare home-manager portion for setup
|
||||||
|
mkdir -p "/etc/nixos/home/hosts/''${hostname}"
|
||||||
|
cat << EOF > "/etc/nixos/home/hosts/''${hostname}/default.nix"
|
||||||
|
{ pkgs, config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Prepares it for injecting the use case into the flake usage
|
||||||
|
cp /etc/nixos.bk/hardware-configuration.nix /etc/nixos
|
||||||
|
chown -R greg nixos
|
||||||
|
|
||||||
|
echo "Now you should be able to just run `nixos-rebuild switch` to enable the flake functionality"
|
||||||
|
echo "After that and adding the entry to the flake, run `nixos-rebuild boot --flake '.#''${hostname}'` and reboot"
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{ writeShellApplication, gh, ... }:
|
||||||
|
|
||||||
|
writeShellApplication {
|
||||||
|
name = "setup-ssh";
|
||||||
|
runtimeInputs = [ gh ];
|
||||||
|
text = builtins.readFile ./setup-ssh.sh;
|
||||||
|
}
|
||||||
@@ -7,5 +7,5 @@ if [ ! -f "${file}" ]; then
|
|||||||
|
|
||||||
echo "Authing key to GitHub - may fail"
|
echo "Authing key to GitHub - may fail"
|
||||||
gh auth refresh -h github.com -s admin:public_key
|
gh auth refresh -h github.com -s admin:public_key
|
||||||
gh ssh-key add -t ${HOSTNAME}-auto "${file}" || true
|
gh ssh-key add -t "${HOSTNAME}-auto" "${file}" || true
|
||||||
fi
|
fi
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
writeShellApplication,
|
||||||
|
postgresql_15,
|
||||||
|
postgresql_16,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
newPostgres = postgresql_16;
|
||||||
|
oldPostgres = postgresql_15;
|
||||||
|
in
|
||||||
|
writeShellApplication {
|
||||||
|
name = "upgrade-pg-cluster";
|
||||||
|
# Only the new one should be in scope, because that is the
|
||||||
|
# one that we will be referencing directly with the sudo command
|
||||||
|
# down farther.
|
||||||
|
runtimeInputs = [ newPostgres ];
|
||||||
|
text = ''
|
||||||
|
systemctl stop postgresql
|
||||||
|
|
||||||
|
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
|
||||||
|
export NEWBIN="${newPostgres}/bin"
|
||||||
|
|
||||||
|
export OLDDATA="/var/lib/postgresql/${oldPostgres.psqlSchema}"
|
||||||
|
export OLDBIN="${oldPostgres}/bin"
|
||||||
|
|
||||||
|
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
||||||
|
cd "$NEWDATA"
|
||||||
|
sudo -u postgres "$NEWBIN/initdb" -D "$NEWDATA"
|
||||||
|
|
||||||
|
sudo -u postgres "$NEWBIN/pg_upgrade" \
|
||||||
|
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
||||||
|
--old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
|
||||||
|
"$@"
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user