Compare commits

..

3 Commits

Author SHA1 Message Date
anmiller
6e88e2b333 Update flakes to support 24.05 and unstable branches 2024-06-07 13:47:48 +00:00
anmiller
4c312cfa58 Ensure persistent history exists 2024-06-07 13:46:39 +00:00
anmiller
11e8bf4bec Improve escaping for PS1 2024-06-07 13:44:14 +00:00
2 changed files with 17 additions and 9 deletions

View File

@ -21,8 +21,8 @@ else
fi fi
export PS1="${green}\$${no_color} " export PS1="${green}"'\$'"${no_color} "
export DIRENV_PS1="${red}\$${no_color} " export DIRENV_PS1="${red}"'\$'"${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}" DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
PS1="${PS1}${blue}${HOSTNAME} ${PS1}" PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
@ -64,6 +64,10 @@ log_bash_persistent_history()
]] ]]
local date_part="${BASH_REMATCH[1]}" local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}" local command_part="${BASH_REMATCH[2]}"
# Ensure file exists
if ! [ -w "$(dirname ${PERSISTENT_HISTFILE})" ]; then
mkdir -p $(dirname ${PERSISTENT_HISTFILE})
fi
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ] if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
then then
echo $date_part "|" "$rc" "|" "$command_part" >> "${PERSISTENT_HISTFILE}" echo $date_part "|" "$rc" "|" "$command_part" >> "${PERSISTENT_HISTFILE}"

View File

@ -35,18 +35,20 @@ nix_packages=(
"kubernetes-helm" "kubernetes-helm"
"rancher" "rancher"
#"terraform"
"opentofu"
"terragrunt"
) )
unstable_packages=( unstable_packages=(
# CVE in NixOS stable version of vault # CVE in NixOS stable version of vault
"vault" "vault"
# Need unstable latest up to date terraform/terragrunt
"terraform"
"terragrunt"
) )
mkdir -p ~/.config/nixpkgs/ mkdir -p ~/.config/nixpkgs/
templated_insert=$(for nix_package in ${nix_packages[@]}; do echo " $nix_package"; done) templated_insert="$(for nix_package in ${nix_packages[@]}; do echo " $nix_package"; echo; done)"
templated_insert=${templated_insert}$(for unstable_package in ${unstable_packages[@]}; do echo; echo " unstablePkgs.$unstable_package"; done)
# Reference: https://discourse.nixos.org/t/nix-profile-in-combination-with-declarative-package-management/21228/9 # Reference: https://discourse.nixos.org/t/nix-profile-in-combination-with-declarative-package-management/21228/9
@ -55,10 +57,11 @@ cat << EOF > ~/.config/nixpkgs/flake.nix
description = "A declarative system installation"; description = "A declarative system installation";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; # also possible: nixos-unstable nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
}; };
outputs = { self, nixpkgs }: outputs = { self, nixpkgs, unstable }:
let let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
@ -69,7 +72,7 @@ cat << EOF > ~/.config/nixpkgs/flake.nix
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types. # Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; config.allowUnfree = true; });
in { in {
packages = forAllSystems (system: packages = forAllSystems (system:
let let
@ -79,6 +82,7 @@ cat << EOF > ~/.config/nixpkgs/flake.nix
myPackageCollection = # libs and clis myPackageCollection = # libs and clis
let let
pkgs = nixpkgs.legacyPackages.\${system}; # here we need just legacy packages pkgs = nixpkgs.legacyPackages.\${system}; # here we need just legacy packages
unstablePkgs = import unstable { inherit system; config.allowUnfree = true; };
in pkgs.buildEnv { in pkgs.buildEnv {
name = "myPackages"; name = "myPackages";
paths = with pkgs; [ paths = with pkgs; [