diff --git a/.gitignore b/.gitignore index 10e0205..81e8f93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ syntax:glob flake.nix +darwin-configuration.nix home-manager/modules/git.nix home-manager/modules/ssh.nix diff --git a/README.md b/README.md index 2bf9fa3..66e4886 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,17 @@ Just run this install script from your terminal: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/risclog-solution/macos-nix-setup/HEAD/install.sh)" ``` +The installation consists of the following steps: + +- MacGPG installieren, Schlüssel erzeugen und hochladen +- Script starten: iTerm2, Developer Tools installieren +- Name/GPGKey/… eingeben, danach immer `y` auswählen +- Determinate Nix installieren +- Script wieder starten, bis Fehler `system activation must now be run as root` kommt +- Script wieder starten, sollte nun fehlerfrei durchlaufen +- Am Ende im iTerm noch `p10k configure` ausführen, damit die Schriftarten passen + + Restore from Time Machine backup -------------------------------- diff --git a/binaries/drop_testdb.sh b/binaries/drop_testdb.sh index 4223574..b83bc12 100755 --- a/binaries/drop_testdb.sh +++ b/binaries/drop_testdb.sh @@ -20,6 +20,6 @@ for entry in db_list.splitlines(): db_name = db_name.decode() if not db_name.startswith(options.prefix): continue - print('dropdb {}'.format(db_name)) + print('dropdb -f {}'.format(db_name)) if not options.dry: - subprocess.check_output(['dropdb', db_name]) + subprocess.check_output(['dropdb', '-f', db_name]) diff --git a/binaries/prepare-commit-msg b/binaries/prepare-commit-msg index 2c86f39..905eecd 100755 --- a/binaries/prepare-commit-msg +++ b/binaries/prepare-commit-msg @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3.10 # # git hook that prefills the commit message with the diff to the changelog file # diff --git a/darwin-configuration.nix b/darwin-configuration.nix.in similarity index 93% rename from darwin-configuration.nix rename to darwin-configuration.nix.in index 1b442c1..26ee3ab 100644 --- a/darwin-configuration.nix +++ b/darwin-configuration.nix.in @@ -16,7 +16,8 @@ # environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix"; # Auto upgrade nix package and the daemon service. - services.nix-daemon.enable = true; + # services.nix-daemon.enable = true; + nix.enable = false; launchd.daemons.nginx = { command = "${pkgs.nginx}/bin/nginx -p /etc/local/nginx/tmp -c /etc/local/nginx/nginx.conf -e /etc/local/nginx/logs/error.log"; @@ -59,5 +60,6 @@ # Used for backwards compatibility, please read the changelog before changing. # $ darwin-rebuild changelog - system.stateVersion = 4; + system.stateVersion = 5; + system.primaryUser = "USERNAME"; } diff --git a/flake.lock b/flake.lock index 71d8e7c..7c772a6 100644 --- a/flake.lock +++ b/flake.lock @@ -44,11 +44,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1754028485, - "narHash": "sha256-IiiXB3BDTi6UqzAZcf2S797hWEPCRZOwyNThJIYhUfk=", + "lastModified": 1754937576, + "narHash": "sha256-3sWA5WJybUE16kIMZ3+uxcxKZY/JRR4DFBqLdSLBo7w=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "59e69648d345d6e8fef86158c555730fa12af9de", + "rev": "ddae11e58c0c345bf66efbddbf2192ed0e58f896", "type": "github" }, "original": { diff --git a/home-manager/modules/common.nix b/home-manager/modules/common.nix index a2fb306..931b625 100644 --- a/home-manager/modules/common.nix +++ b/home-manager/modules/common.nix @@ -9,6 +9,9 @@ ]; nixpkgs.config.allowUnsupportedSystem = true; + nixpkgs.config.permittedInsecurePackages = [ + "python-2.7.18.8" + ]; home.packages = with pkgs; [ gnused.out @@ -34,11 +37,13 @@ libxcrypt libargon2 tesseract + ollama # mailsend # currently not supported under M1 haskellPackages.cryptohash-sha256 libxml2 readline postgresql_14.dev + postgresql_14.pg_config file ruby binutils @@ -78,7 +83,7 @@ tree # better du alternative du-dust - awscli + awscli2 graphviz git-crypt @@ -86,8 +91,8 @@ yarn neovim + python27 python310 - python311 python312Full jq cloc diff --git a/install.sh b/install.sh index edd3151..8bd988b 100755 --- a/install.sh +++ b/install.sh @@ -176,7 +176,7 @@ fi if [ -d "$RL_CHECKOUT" ] then ohai "Checkout dir $RL_CHECKOUT already exists. Updating." - cd $RL_CHECKOUT && git checkout -- . && git pull + cd $RL_CHECKOUT && git pull else ohai "Checkout dir $RL_CHECKOUT does not exist. Creating." execute_sudo "${MKDIR[@]}" "${RL_CHECKOUT}" @@ -205,6 +205,7 @@ else fi cp flake.nix.in flake.nix +cp darwin-configuration.nix.in darwin-configuration.nix cp home-manager/modules/git.nix.in home-manager/modules/git.nix cp home-manager/modules/ssh.nix.in home-manager/modules/ssh.nix @@ -212,6 +213,7 @@ sed -i -- "s/HOSTNAME/$(scutil --get LocalHostName)/" flake.nix ohai "Change config to current user $USER" sed -i -- "s/USERNAME/$USER/" flake.nix +sed -i -- "s/USERNAME/$USER/" darwin-configuration.nix if ! [[ -n $USERFULLNAME ]] @@ -261,35 +263,33 @@ echo "USEONEPASSWORDAGENT=\"$USEONEPASSWORDAGENT\"" >> $CONFIG if ! [[ -x "$(command -v nix-env)" ]] then - ohai "Installing nix. Answer always y." - NIX_FIRST_BUILD_UID=30001 sh <(curl -L https://releases.nixos.org/nix/nix-2.24.6/install) -fi -if ! [[ -x "$(command -v nix-env)" ]] -then - ohai "Please restart terminal to finish Nix installation" + ohai "Please install Nix via https://docs.determinate.systems, the rerun script" exit 1 fi -#ohai "Updating nix flakes" -#mkdir -p /Users/$USER/.nixpkgs/ -#mkdir -p "/Users/$USER/.config/nix/" -#echo "experimental-features = nix-command flakes" > "/Users/$USER/.config/nix/nix.conf" -#cp darwin-configuration.nix /Users/$USER/.nixpkgs/ -#if ! [[ -x "$(command -v darwin-rebuild)" ]] -#then -# nix flake update --flake path:/opt/nixpkgs/ -# nix run nix-darwin -- switch --flake path:/opt/nixpkgs/ -# # If darwin-rebuild is not found in PATH, try to find it in /nix/store and -# # run the command above by hand -#else -# sudo darwin-rebuild switch --flake path:/opt/nixpkgs/ -#fi +DRRUN=$(ls /nix/store | grep 'darwin-rebuild$' | head -n 1) + +mkdir -p /Users/$USER/.nixpkgs/ +mkdir -p "/Users/$USER/.config/nix/" +echo "experimental-features = nix-command flakes" > "/Users/$USER/.config/nix/nix.conf" +cp darwin-configuration.nix /Users/$USER/.nixpkgs/ + +if [ -z "$DRRUN" ]; then + ohai "Installing nix flakes" + nix flake update --flake path:/opt/nixpkgs/ + nix run nix-darwin -- switch --flake path:/opt/nixpkgs/ +fi + +ohai "Updating nix flakes" +sudo "/nix/store/$DRRUN/bin/darwin-rebuild" switch --flake path:/opt/nixpkgs/ + if ! [[ -x "$(command -v home-manager)" ]] then ohai "Installing home manager" - # nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz home-manager - # nix-channel --update + nix-channel --add https://channels.nixos.org/nixos-25.05 nixpkgs + nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz home-manager + nix-channel --update NIX_PATH="/Users/$USER/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixpkgs:/nix/var/nix/profiles/per-user/root/channels" nix-shell '' -A install fi @@ -301,7 +301,8 @@ if ! [ -d "/etc/local/postgres/data" ] then execute_sudo "${MKDIR[@]}" "/etc/local/postgres/data" execute_sudo "${CHOWN[@]}" "-R" "${USER}:${GROUP}" "/etc/local/postgres" - initdb /etc/local/postgres/data + INITDBRUN=$(ls /nix/store | grep 'postgresql-14.18$' | head -n 1) + /nix/store/$INITDBRUN/bin/initdb /etc/local/postgres/data fi if ! [ -d "/etc/local/redis" ] @@ -375,6 +376,12 @@ then pipx install ruff fi + if ! [[ -x "$(command -v virtualenv)" ]] + then + ohai "Installing virtualenv." + pipx install "virtualenv<20.0.0" + fi + if ! [[ -x "$(command -v flake8)" ]] then ohai "Installing flake8." @@ -399,6 +406,8 @@ if [ ! -d "/usr/local/lib" ]; then sudo ln -s ~/.nix-profile/lib /usr/local/ fi +sudo rm -rf /Users/$USER/.nix-profile/bin/gpg + ohai "Opening iTerm, your new terminal app. If fonts are not shown correctly, run 'p10k configure' once to install NerdFont." open -a iTerm . ohai "Installation successfull. Please close this window now."