From f3a488df07f104deefa26a3632aaf6b88a9cfcea Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 14:16:57 -0300 Subject: [PATCH 001/191] WIP --- .idea/.github.iml | 8 + .idea/.gitignore | 3 + .../inspectionProfiles/profiles_settings.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + README.md | 588 ++++++++++++++++++ 6 files changed, 619 insertions(+) create mode 100644 .idea/.github.iml create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.github.iml b/.idea/.github.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/.github.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..854e742 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 5a86cfe..8ae3194 100644 --- a/README.md +++ b/README.md @@ -1 +1,589 @@ # .github + + +## Slim, home-manager + nix + zsh + fonts + + +```bash +command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) +command -v curl || (command -v apk && sudo apk add --no-cache -y curl) + +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ +&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh + +export NIX_CONFIG='extra-experimental-features = nix-command flakes' + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF + + echo $PATH | tr ':' '\n' + + { + mkdir -pv /home/"$USER"/.config/nixpkgs \ + && ls -al /home/"$USER"/.config/nixpkgs \ + && tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' + { pkgs, ... }: + + { + + home.packages = with pkgs; [ + btop + coreutils + curl + git + jq + neovim + openssh + shadow + tmate + zsh + + ( + writeScriptBin "ix" '' + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "gphms" '' + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + nix repl --expr 'import {}' + '' + ) + + ( + writeScriptBin "nfm" '' + #! \${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) + + ]; + + nix = { + enable = true; + package = pkgs.nixVersions.nix_2_10; + extraOptions = "experimental-features = nix-command flakes"; + }; + + # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ + programs.zsh = { + # Your zsh config + enable = true; + enableCompletion = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + envExtra = '' + if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then + . ~/.nix-profile/etc/profile.d/nix.sh + fi + ''; + + # > closed and reopened the terminal. Then it worked. + # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 + sessionVariables = { + LANG = "en_US.utf8"; + }; + + historySubstringSearch.enable = true; + + history = { + save = 50000; + size = 50000; + path = "$HOME/.cache/zsh_history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + # plugins = (import ./zsh/plugins.nix) pkgs; + # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix + plugins = [ + "colored-man-pages" + "colorize" + "fzf" + "git" + "git-extras" + "github" + "gitignore" + "history" + "history-substring-search" + "man" + "ssh-agent" + "sudo" + "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin + "zsh-navigation-tools" + ]; + theme = "robbyrussell"; + }; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + shell = { disabled = false; }; + rlang = { detect_files = [ ]; }; + python = { disabled = true; }; + }; + }; + + programs.home-manager = { + enable = true; + }; + } +NESTEDEOF + + +tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' + { + description = "Home Manager configuration"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "vagrant"; + in { + homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.\${system}; + + modules = [ + { + home = { + inherit username; + # TODO: esse caminho muda no Mac! + homeDirectory = "/home/\${username}"; + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; + } +NESTEDEOF +} && echo 1234 \ +&& cd /home/"$USER"/.config/nixpkgs/ \ +&& echo 5678 \ +&& sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ +&& git init \ +&& git status \ +&& git add . \ +&& nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ +&& git status \ +&& git add . + +# Estas linhas precisam das variáveis de ambiente USER e HOME +export NIXPKGS_ALLOW_UNFREE=1 \ +&& home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ +&& home-manager generations + + +# +TARGET_SHELL='zsh' \ +&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ +&& echo \ +&& ls -al "\$FULL_TARGET_SHELL" \ +&& echo \ +&& echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ +&& echo \ +&& sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF + +# sudo reboot + +``` + + + +## Broken + + +```bash +command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) +command -v curl || (command -v apk && sudo apk add --no-cache -y curl) + +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ +&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh + +export NIX_CONFIG='extra-experimental-features = nix-command flakes' + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF +{ + + mkdir -pv /home/"$USER"/.config/nixpkgs \ + && ls -al /home/"$USER"/.config/nixpkgs + + tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' + { pkgs, ... }: + { + + home.packages = with pkgs; [ + btop + coreutils + curl + git + jq + neovim + openssh + shadow + tmate + zsh + + # + nerdfonts + + # Graphical +# 1password-gui +# discord +# gimp +# gitkraken +# google-chrome +# kolourpaint +# obsidian +# qbittorrent +# slack +# spotify +# tdesktop +# vscodium + + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "${HOME}"/.ssh/id_ed25519 \ + -N '' \ + && echo \ + && cat "${HOME}"/.ssh/id_ed25519.pub \ + && echo + '' + ) + + ( + writeScriptBin "gphms" '' + #! ${pkgs.runtimeShell} -e + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + #! ${pkgs.runtimeShell} -e + nix repl --expr 'import {}' + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) + ]; + + nix = { + enable = true; + package = pkgs.nixVersions.nix_2_10; + extraOptions = '' + experimental-features = nix-command flakes + ''; + + settings = { + # use-sandbox = true; + show-trace = false; + keep-outputs = true; + keep-derivations = true; + + # One month: 60 * 60 * 24 * 7 * 4 = 2419200 + tarball-ttl = 60 * 60 * 24 * 7 * 4; + }; + }; + + nixpkgs.config = { + allowBroken = false; + allowUnfree = true; + }; + + + fonts = { + fontconfig = { + enable = true; + }; + }; + + home.extraOutputsToInstall = [ + "/share/zsh" + "/share/bash" + "/share/fish" + "/share/fonts" # fc-cache -frv + # /etc/fonts + ]; + + # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ + programs.zsh = { + # Your zsh config + enable = true; + enableCompletion = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + envExtra = '' + if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then + . ~/.nix-profile/etc/profile.d/nix.sh + fi + ''; + + initExtra = "${pkgs.neofetch}/bin/neofetch"; + autocd = true; + + # > closed and reopened the terminal. Then it worked. + # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 + sessionVariables = { + LANG = "en_US.utf8"; + # fc-match list + FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; + }; + + historySubstringSearch.enable = true; + + history = { + save = 50000; + size = 50000; + path = "$HOME/.cache/zsh_history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + # plugins = (import ./zsh/plugins.nix) pkgs; + # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix + plugins = [ + # "autojump" + "aws" + # "cargo" + "catimg" + "colored-man-pages" + "colorize" + "command-not-found" + "common-aliases" + "copyfile" + "copypath" + "cp" + "direnv" + "docker" + "docker-compose" + "emacs" + "encode64" + "extract" + "fancy-ctrl-z" + "fzf" + "gcloud" + "git" + "git-extras" + "git-flow-avh" + "github" + "gitignore" + "gradle" + "history" + "history-substring-search" + "kubectl" + "man" + "mvn" + "node" + "npm" + "pass" + "pip" + "poetry" + "python" + "ripgrep" + "rsync" + "rust" + "scala" + "ssh-agent" + "sudo" + "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin + "systemd" + "terraform" + # "thefuck" + "tig" + "timer" + # "tmux" # It needs to be installed + "vagrant" + "vi-mode" + "vim-interaction" + "yarn" + "z" + "zsh-navigation-tools" + ]; + theme = "robbyrussell"; + # theme = "bira"; + # theme = "powerlevel10k"; + # theme = "powerlevel9k/powerlevel9k"; + # theme = "agnoster"; + # theme = "gallois"; + # theme = "gentoo"; + # theme = "af-magic"; + # theme = "half-life"; + # theme = "rgm"; + # theme = "crcandy"; + # theme = "fishy"; + }; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + shell = { disabled = false; }; + rlang = { detect_files = [ ]; }; + python = { disabled = true; }; + }; + }; + + programs.home-manager = { + enable = true; + }; + } +NESTEDEOF + + +tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' + { + description = "Home Manager configuration"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "vagrant"; + in { + homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.\${system}; + + modules = [ + { + home = { + inherit username; + # TODO: esse caminho muda no Mac! + homeDirectory = "/home/\${username}"; + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; + } +NESTEDEOF + + echo \ + && cd /home/"$USER"/.config/nixpkgs/ \ + && sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ + && git init \ + && git status \ + && git add . \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && git status \ + && git add . + + # Estas linhas precisam das variáveis de ambiente USER e HOME + export NIXPKGS_ALLOW_UNFREE=1 \ + && home-manager switch -b backuphm --impure --flake "$HOME"/.config/nixpkgs \ + && home-manager generations + + # + TARGET_SHELL='zsh' \ + && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + && echo \ + && ls -al "\$FULL_TARGET_SHELL" \ + && echo \ + && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ + && echo \ + && sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF + +# sudo reboot +``` From 71affd7c5c67d5d9b28f53832931aea3492549a0 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 14:18:01 -0300 Subject: [PATCH 002/191] SAbia que eu ia esquecer o .idea --- .idea/.github.iml | 8 -------- .idea/.gitignore | 3 --- .idea/inspectionProfiles/profiles_settings.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 5 files changed, 31 deletions(-) delete mode 100644 .idea/.github.iml delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.github.iml b/.idea/.github.iml deleted file mode 100644 index d0876a7..0000000 --- a/.idea/.github.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 854e742..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From e85314dc31d8184462d073e33b296e02c9fb4b55 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 16:11:17 -0300 Subject: [PATCH 003/191] =?UTF-8?q?Move=20c=C3=B3digos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 53 ++++ README.md | 588 ------------------------------------------- profile/README.md | 594 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 639 insertions(+), 596 deletions(-) create mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..d024f78 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "last_opened_file_path": "/home/pedro/Documents/work/.github" + } +} + + + + + 1678323845407 + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 8ae3194..5a86cfe 100644 --- a/README.md +++ b/README.md @@ -1,589 +1 @@ # .github - - -## Slim, home-manager + nix + zsh + fonts - - -```bash -command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) -command -v curl || (command -v apk && sudo apk add --no-cache -y curl) - -NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ -&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh - -export NIX_CONFIG='extra-experimental-features = nix-command flakes' - -nix \ -shell \ -github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ ---command \ -bash <<-EOF - - echo $PATH | tr ':' '\n' - - { - mkdir -pv /home/"$USER"/.config/nixpkgs \ - && ls -al /home/"$USER"/.config/nixpkgs \ - && tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' - { pkgs, ... }: - - { - - home.packages = with pkgs; [ - btop - coreutils - curl - git - jq - neovim - openssh - shadow - tmate - zsh - - ( - writeScriptBin "ix" '' - "$@" | "curl" -F 'f:1=<-' ix.io - '' - ) - - ( - writeScriptBin "gphms" '' - echo $(cd "$HOME/.config/nixpkgs" && git pull) \ - && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" - '' - ) - - ( - writeScriptBin "nr" '' - nix repl --expr 'import {}' - '' - ) - - ( - writeScriptBin "nfm" '' - #! \${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) - - ]; - - nix = { - enable = true; - package = pkgs.nixVersions.nix_2_10; - extraOptions = "experimental-features = nix-command flakes"; - }; - - # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ - programs.zsh = { - # Your zsh config - enable = true; - enableCompletion = true; - dotDir = ".config/zsh"; - enableAutosuggestions = true; - enableSyntaxHighlighting = true; - envExtra = '' - if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then - . ~/.nix-profile/etc/profile.d/nix.sh - fi - ''; - - # > closed and reopened the terminal. Then it worked. - # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 - sessionVariables = { - LANG = "en_US.utf8"; - }; - - historySubstringSearch.enable = true; - - history = { - save = 50000; - size = 50000; - path = "$HOME/.cache/zsh_history"; - expireDuplicatesFirst = true; - }; - - oh-my-zsh = { - enable = true; - # plugins = (import ./zsh/plugins.nix) pkgs; - # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix - plugins = [ - "colored-man-pages" - "colorize" - "fzf" - "git" - "git-extras" - "github" - "gitignore" - "history" - "history-substring-search" - "man" - "ssh-agent" - "sudo" - "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin - "zsh-navigation-tools" - ]; - theme = "robbyrussell"; - }; - }; - - programs.fzf = { - enable = true; - enableZshIntegration = true; - }; - - programs.starship = { - enable = true; - enableZshIntegration = true; - settings = { - shell = { disabled = false; }; - rlang = { detect_files = [ ]; }; - python = { disabled = true; }; - }; - }; - - programs.home-manager = { - enable = true; - }; - } -NESTEDEOF - - -tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' - { - description = "Home Manager configuration"; - - inputs = { - # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; - - outputs = { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - username = "vagrant"; - in { - homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.\${system}; - - modules = [ - { - home = { - inherit username; - # TODO: esse caminho muda no Mac! - homeDirectory = "/home/\${username}"; - stateVersion = "22.11"; - }; - programs.home-manager.enable = true; - } - ./home.nix - ]; - - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; - }; - } -NESTEDEOF -} && echo 1234 \ -&& cd /home/"$USER"/.config/nixpkgs/ \ -&& echo 5678 \ -&& sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ -&& git init \ -&& git status \ -&& git add . \ -&& nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ -&& git status \ -&& git add . - -# Estas linhas precisam das variáveis de ambiente USER e HOME -export NIXPKGS_ALLOW_UNFREE=1 \ -&& home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ -&& home-manager generations - - -# -TARGET_SHELL='zsh' \ -&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ -&& echo \ -&& ls -al "\$FULL_TARGET_SHELL" \ -&& echo \ -&& echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ -&& echo \ -&& sudo \ - -k \ - usermod \ - -s \ - /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - "$USER" -EOF - -# sudo reboot - -``` - - - -## Broken - - -```bash -command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) -command -v curl || (command -v apk && sudo apk add --no-cache -y curl) - -NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ -&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh - -export NIX_CONFIG='extra-experimental-features = nix-command flakes' - -nix \ -shell \ -github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ ---command \ -bash <<-EOF -{ - - mkdir -pv /home/"$USER"/.config/nixpkgs \ - && ls -al /home/"$USER"/.config/nixpkgs - - tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' - { pkgs, ... }: - { - - home.packages = with pkgs; [ - btop - coreutils - curl - git - jq - neovim - openssh - shadow - tmate - zsh - - # - nerdfonts - - # Graphical -# 1password-gui -# discord -# gimp -# gitkraken -# google-chrome -# kolourpaint -# obsidian -# qbittorrent -# slack -# spotify -# tdesktop -# vscodium - - ( - writeScriptBin "ix" '' - #! ${pkgs.runtimeShell} -e - "$@" | "curl" -F 'f:1=<-' ix.io - '' - ) - ( - writeScriptBin "erw" '' - #! ${pkgs.runtimeShell} -e - echo "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "crw" '' - #! ${pkgs.runtimeShell} -e - cat "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "generate-new-ed25519-key-pair" '' - #! ${pkgs.runtimeShell} -e - ssh-keygen \ - -t ed25519 \ - -C "$(git config user.email)" \ - -f "${HOME}"/.ssh/id_ed25519 \ - -N '' \ - && echo \ - && cat "${HOME}"/.ssh/id_ed25519.pub \ - && echo - '' - ) - - ( - writeScriptBin "gphms" '' - #! ${pkgs.runtimeShell} -e - echo $(cd "$HOME/.config/nixpkgs" && git pull) \ - && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" - '' - ) - - ( - writeScriptBin "nr" '' - #! ${pkgs.runtimeShell} -e - nix repl --expr 'import {}' - '' - ) - - ( - writeScriptBin "nfm" '' - #! ${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) - ]; - - nix = { - enable = true; - package = pkgs.nixVersions.nix_2_10; - extraOptions = '' - experimental-features = nix-command flakes - ''; - - settings = { - # use-sandbox = true; - show-trace = false; - keep-outputs = true; - keep-derivations = true; - - # One month: 60 * 60 * 24 * 7 * 4 = 2419200 - tarball-ttl = 60 * 60 * 24 * 7 * 4; - }; - }; - - nixpkgs.config = { - allowBroken = false; - allowUnfree = true; - }; - - - fonts = { - fontconfig = { - enable = true; - }; - }; - - home.extraOutputsToInstall = [ - "/share/zsh" - "/share/bash" - "/share/fish" - "/share/fonts" # fc-cache -frv - # /etc/fonts - ]; - - # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ - programs.zsh = { - # Your zsh config - enable = true; - enableCompletion = true; - dotDir = ".config/zsh"; - enableAutosuggestions = true; - enableSyntaxHighlighting = true; - envExtra = '' - if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then - . ~/.nix-profile/etc/profile.d/nix.sh - fi - ''; - - initExtra = "${pkgs.neofetch}/bin/neofetch"; - autocd = true; - - # > closed and reopened the terminal. Then it worked. - # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 - sessionVariables = { - LANG = "en_US.utf8"; - # fc-match list - FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; - FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; - }; - - historySubstringSearch.enable = true; - - history = { - save = 50000; - size = 50000; - path = "$HOME/.cache/zsh_history"; - expireDuplicatesFirst = true; - }; - - oh-my-zsh = { - enable = true; - # plugins = (import ./zsh/plugins.nix) pkgs; - # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix - plugins = [ - # "autojump" - "aws" - # "cargo" - "catimg" - "colored-man-pages" - "colorize" - "command-not-found" - "common-aliases" - "copyfile" - "copypath" - "cp" - "direnv" - "docker" - "docker-compose" - "emacs" - "encode64" - "extract" - "fancy-ctrl-z" - "fzf" - "gcloud" - "git" - "git-extras" - "git-flow-avh" - "github" - "gitignore" - "gradle" - "history" - "history-substring-search" - "kubectl" - "man" - "mvn" - "node" - "npm" - "pass" - "pip" - "poetry" - "python" - "ripgrep" - "rsync" - "rust" - "scala" - "ssh-agent" - "sudo" - "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin - "systemd" - "terraform" - # "thefuck" - "tig" - "timer" - # "tmux" # It needs to be installed - "vagrant" - "vi-mode" - "vim-interaction" - "yarn" - "z" - "zsh-navigation-tools" - ]; - theme = "robbyrussell"; - # theme = "bira"; - # theme = "powerlevel10k"; - # theme = "powerlevel9k/powerlevel9k"; - # theme = "agnoster"; - # theme = "gallois"; - # theme = "gentoo"; - # theme = "af-magic"; - # theme = "half-life"; - # theme = "rgm"; - # theme = "crcandy"; - # theme = "fishy"; - }; - }; - - programs.fzf = { - enable = true; - enableZshIntegration = true; - }; - - programs.starship = { - enable = true; - enableZshIntegration = true; - settings = { - shell = { disabled = false; }; - rlang = { detect_files = [ ]; }; - python = { disabled = true; }; - }; - }; - - programs.home-manager = { - enable = true; - }; - } -NESTEDEOF - - -tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' - { - description = "Home Manager configuration"; - - inputs = { - # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; - - outputs = { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - username = "vagrant"; - in { - homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.\${system}; - - modules = [ - { - home = { - inherit username; - # TODO: esse caminho muda no Mac! - homeDirectory = "/home/\${username}"; - stateVersion = "22.11"; - }; - programs.home-manager.enable = true; - } - ./home.nix - ]; - - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; - }; - } -NESTEDEOF - - echo \ - && cd /home/"$USER"/.config/nixpkgs/ \ - && sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ - && git init \ - && git status \ - && git add . \ - && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ - && git status \ - && git add . - - # Estas linhas precisam das variáveis de ambiente USER e HOME - export NIXPKGS_ALLOW_UNFREE=1 \ - && home-manager switch -b backuphm --impure --flake "$HOME"/.config/nixpkgs \ - && home-manager generations - - # - TARGET_SHELL='zsh' \ - && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - && echo \ - && ls -al "\$FULL_TARGET_SHELL" \ - && echo \ - && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ - && echo \ - && sudo \ - -k \ - usermod \ - -s \ - /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - "$USER" -EOF - -# sudo reboot -``` diff --git a/profile/README.md b/profile/README.md index da795aa..46eb4c7 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1,12 +1,590 @@ # Hi there 👋 - +## Slim, home-manager + nix + zsh + fonts + + +```bash +command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) +command -v curl || (command -v apk && sudo apk add --no-cache -y curl) + +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ +&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh + +export NIX_CONFIG='extra-experimental-features = nix-command flakes' + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF + + echo $PATH | tr ':' '\n' + + { + mkdir -pv /home/"$USER"/.config/nixpkgs \ + && ls -al /home/"$USER"/.config/nixpkgs \ + && tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' + { pkgs, ... }: + + { + + home.packages = with pkgs; [ + btop + coreutils + curl + git + jq + neovim + openssh + shadow + tmate + zsh + + ( + writeScriptBin "ix" '' + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "gphms" '' + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + nix repl --expr 'import {}' + '' + ) + + ( + writeScriptBin "nfm" '' + #! \${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) + + ]; + + nix = { + enable = true; + package = pkgs.nixVersions.nix_2_10; + extraOptions = "experimental-features = nix-command flakes"; + }; + + # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ + programs.zsh = { + # Your zsh config + enable = true; + enableCompletion = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + envExtra = '' + if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then + . ~/.nix-profile/etc/profile.d/nix.sh + fi + ''; + + # > closed and reopened the terminal. Then it worked. + # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 + sessionVariables = { + LANG = "en_US.utf8"; + }; + + historySubstringSearch.enable = true; + + history = { + save = 50000; + size = 50000; + path = "$HOME/.cache/zsh_history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + # plugins = (import ./zsh/plugins.nix) pkgs; + # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix + plugins = [ + "colored-man-pages" + "colorize" + "fzf" + "git" + "git-extras" + "github" + "gitignore" + "history" + "history-substring-search" + "man" + "ssh-agent" + "sudo" + "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin + "zsh-navigation-tools" + ]; + theme = "robbyrussell"; + }; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + shell = { disabled = false; }; + rlang = { detect_files = [ ]; }; + python = { disabled = true; }; + }; + }; + + programs.home-manager = { + enable = true; + }; + } +NESTEDEOF + + +tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' + { + description = "Home Manager configuration"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "vagrant"; + in { + homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.\${system}; + + modules = [ + { + home = { + inherit username; + # TODO: esse caminho muda no Mac! + homeDirectory = "/home/\${username}"; + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; + } +NESTEDEOF +} && echo 1234 \ +&& cd /home/"$USER"/.config/nixpkgs/ \ +&& echo 5678 \ +&& sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ +&& git init \ +&& git status \ +&& git add . \ +&& nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ +&& git status \ +&& git add . + +# Estas linhas precisam das variáveis de ambiente USER e HOME +export NIXPKGS_ALLOW_UNFREE=1 \ +&& home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ +&& home-manager generations + + +# +TARGET_SHELL='zsh' \ +&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ +&& echo \ +&& ls -al "\$FULL_TARGET_SHELL" \ +&& echo \ +&& echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ +&& echo \ +&& sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF + +# sudo reboot + +``` + + + +## Broken + + +```bash +command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) +command -v curl || (command -v apk && sudo apk add --no-cache -y curl) + +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ +&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh + +export NIX_CONFIG='extra-experimental-features = nix-command flakes' + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF +{ + + mkdir -pv /home/"$USER"/.config/nixpkgs \ + && ls -al /home/"$USER"/.config/nixpkgs + + tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' + { pkgs, ... }: + { + + home.packages = with pkgs; [ + btop + coreutils + curl + git + jq + neovim + openssh + shadow + tmate + zsh + + # + nerdfonts + + # Graphical +# 1password-gui +# discord +# gimp +# gitkraken +# google-chrome +# kolourpaint +# obsidian +# qbittorrent +# slack +# spotify +# tdesktop +# vscodium + + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "${HOME}"/.ssh/id_ed25519 \ + -N '' \ + && echo \ + && cat "${HOME}"/.ssh/id_ed25519.pub \ + && echo + '' + ) + + ( + writeScriptBin "gphms" '' + #! ${pkgs.runtimeShell} -e + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + #! ${pkgs.runtimeShell} -e + nix repl --expr 'import {}' + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) + ]; + + nix = { + enable = true; + package = pkgs.nixVersions.nix_2_10; + extraOptions = '' + experimental-features = nix-command flakes + ''; + + settings = { + # use-sandbox = true; + show-trace = false; + keep-outputs = true; + keep-derivations = true; + + # One month: 60 * 60 * 24 * 7 * 4 = 2419200 + tarball-ttl = 60 * 60 * 24 * 7 * 4; + }; + }; + + nixpkgs.config = { + allowBroken = false; + allowUnfree = true; + }; + + + fonts = { + fontconfig = { + enable = true; + }; + }; + + home.extraOutputsToInstall = [ + "/share/zsh" + "/share/bash" + "/share/fish" + "/share/fonts" # fc-cache -frv + # /etc/fonts + ]; + + # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ + programs.zsh = { + # Your zsh config + enable = true; + enableCompletion = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + envExtra = '' + if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then + . ~/.nix-profile/etc/profile.d/nix.sh + fi + ''; + + initExtra = "${pkgs.neofetch}/bin/neofetch"; + autocd = true; + + # > closed and reopened the terminal. Then it worked. + # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 + sessionVariables = { + LANG = "en_US.utf8"; + # fc-match list + FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; + }; + + historySubstringSearch.enable = true; + + history = { + save = 50000; + size = 50000; + path = "$HOME/.cache/zsh_history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + # plugins = (import ./zsh/plugins.nix) pkgs; + # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix + plugins = [ + # "autojump" + "aws" + # "cargo" + "catimg" + "colored-man-pages" + "colorize" + "command-not-found" + "common-aliases" + "copyfile" + "copypath" + "cp" + "direnv" + "docker" + "docker-compose" + "emacs" + "encode64" + "extract" + "fancy-ctrl-z" + "fzf" + "gcloud" + "git" + "git-extras" + "git-flow-avh" + "github" + "gitignore" + "gradle" + "history" + "history-substring-search" + "kubectl" + "man" + "mvn" + "node" + "npm" + "pass" + "pip" + "poetry" + "python" + "ripgrep" + "rsync" + "rust" + "scala" + "ssh-agent" + "sudo" + "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin + "systemd" + "terraform" + # "thefuck" + "tig" + "timer" + # "tmux" # It needs to be installed + "vagrant" + "vi-mode" + "vim-interaction" + "yarn" + "z" + "zsh-navigation-tools" + ]; + theme = "robbyrussell"; + # theme = "bira"; + # theme = "powerlevel10k"; + # theme = "powerlevel9k/powerlevel9k"; + # theme = "agnoster"; + # theme = "gallois"; + # theme = "gentoo"; + # theme = "af-magic"; + # theme = "half-life"; + # theme = "rgm"; + # theme = "crcandy"; + # theme = "fishy"; + }; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + shell = { disabled = false; }; + rlang = { detect_files = [ ]; }; + python = { disabled = true; }; + }; + }; + + programs.home-manager = { + enable = true; + }; + } +NESTEDEOF + + +tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' + { + description = "Home Manager configuration"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "vagrant"; + in { + homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.\${system}; + + modules = [ + { + home = { + inherit username; + # TODO: esse caminho muda no Mac! + homeDirectory = "/home/\${username}"; + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; + } +NESTEDEOF + + echo \ + && cd /home/"$USER"/.config/nixpkgs/ \ + && sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ + && git init \ + && git status \ + && git add . \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && git status \ + && git add . + + # Estas linhas precisam das variáveis de ambiente USER e HOME + export NIXPKGS_ALLOW_UNFREE=1 \ + && home-manager switch -b backuphm --impure --flake "$HOME"/.config/nixpkgs \ + && home-manager generations + + # + TARGET_SHELL='zsh' \ + && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + && echo \ + && ls -al "\$FULL_TARGET_SHELL" \ + && echo \ + && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ + && echo \ + && sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF + +# sudo reboot +``` From 498430996eae31c938003620f1c1d0b565ed6322 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 16:11:35 -0300 Subject: [PATCH 004/191] SAbia que eu ia esquecer o .idea --- .idea/workspace.xml | 53 --------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index d024f78..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - { - "keyToString": { - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "last_opened_file_path": "/home/pedro/Documents/work/.github" - } -} - - - - - 1678323845407 - - - - - - - \ No newline at end of file From a1a23abae542ea6368470d987d4f5b84d58ebe31 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 16:12:04 -0300 Subject: [PATCH 005/191] Adiciona .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ From 27094ff4145f8fd14c93e1098f66d0ecd946c2de Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 23:40:13 -0300 Subject: [PATCH 006/191] Teste de template --- flake.lock | 41 + flake.nix | 58 + profile/README.md | 66 + templates/default.nix | 6 + .../start-config-graphical-full/flake.nix | 35 + .../start-config-graphical-full/home.nix | 1441 +++++++++++++++++ 6 files changed, 1647 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 templates/default.nix create mode 100644 templates/start-config-graphical-full/flake.nix create mode 100644 templates/start-config-graphical-full/home.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..aecaf9d --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678298120, + "narHash": "sha256-iaV5xqgn29xy765Js3EoZePQyZIlLZA3pTYtTnKkejg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1e383aada51b416c6c27d4884d2e258df201bc11", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..aa0c6c4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Este é o entrypoint público do Imobanco para desenvolvedores, sim um 'nix flake' :)"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + flake-utils + }: + flake-utils.lib.eachDefaultSystem (system: + let + name = "imobanco-entrypoint"; + + pkgsAllowUnfree = import nixpkgs { + inherit system; + config = { allowUnfree = true; }; + }; + + in + rec { + + templates = import ./templates; + + packages.checkNixFormat = pkgsAllowUnfree.runCommand "check-nix-format" { } '' + ${pkgsAllowUnfree.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} + + # For fix + # find . -type f -iname '*.nix' -exec nixpkgs-fmt {} \; + + mkdir $out #sucess + ''; + + apps.${name} = flake-utils.lib.mkApp { + inherit name; + drv = packages.${name}; + }; + + devShells.default = pkgsAllowUnfree.mkShell { + buildInputs = with pkgsAllowUnfree; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; + + shellHook = '' + echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat + ''; + }; + }); +} diff --git a/profile/README.md b/profile/README.md index 46eb4c7..b118712 100644 --- a/profile/README.md +++ b/profile/README.md @@ -2,6 +2,72 @@ +## Template + +```bash +command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) +command -v curl || (command -v apk && sudo apk add --no-cache -y curl) + + +# Precisa das variáveis de ambiente USER e HOME +DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#coreutils} \ +--command \ +bash <<-EOF + mkdir -pv $DIRETORY_TO_CLONE +EOF + +cd $DIRETORY_TO_CLONE + +nix \ +flake \ +init \ +--template \ +github:PedroRegisPOAR/.github#start-config-graphical-full + + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF + +sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ +&& git init \ +&& git status \ +&& git add . \ +&& nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ +&& git status \ +&& git add . + + +export NIXPKGS_ALLOW_UNFREE=1 \ +&& home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ +&& home-manager generations + + +# +TARGET_SHELL='zsh' \ +&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ +&& echo \ +&& ls -al "\$FULL_TARGET_SHELL" \ +&& echo \ +&& echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ +&& echo \ +&& sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF +``` + + + ## Slim, home-manager + nix + zsh + fonts diff --git a/templates/default.nix b/templates/default.nix new file mode 100644 index 0000000..564416e --- /dev/null +++ b/templates/default.nix @@ -0,0 +1,6 @@ +{ + baseStartConfigGraphicalFull = { + description = "Configuração base inicial COM insterface gráfica"; + path = ./start-config-graphical-full; + }; +} diff --git a/templates/start-config-graphical-full/flake.nix b/templates/start-config-graphical-full/flake.nix new file mode 100644 index 0000000..440e87f --- /dev/null +++ b/templates/start-config-graphical-full/flake.nix @@ -0,0 +1,35 @@ + { + description = "Home Manager configuration"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "1M0b4nc0"; + in { + homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + + modules = [ + { + home = { + inherit username; + homeDirectory = "/home/\${username}"; # TODO: esse caminho muda no Mac! + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; + + # TODO: how to: Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; + } diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix new file mode 100644 index 0000000..4adf987 --- /dev/null +++ b/templates/start-config-graphical-full/home.nix @@ -0,0 +1,1441 @@ +{ pkgs, ... }: + +{ + + # Home Manager needs a bit of information about you and the + # paths it should manage. + # home.username = "ubuntu"; + # home.homeDirectory = "/home/ubuntu"; + + home.packages = with pkgs; [ + # Graphical packages + #brave + #dbeaver + #discord + gimp + gitkraken + inkscape + insomnia + postman + jetbrains.pycharm-community + keepassxc + kolourpaint + libreoffice + obsidian + okular + peek + #spotify + #tdesktop + vlc + vscodium + blender + #google-chrome + #virt-manager + #anydesk + + # Fun + # qbittorrent + + # sudo $(which lshw) -C display + # sudo dmesg | grep drm + # glxgears -info + # lspci | grep -i vga + # mesa + # mesa-demos + # libglvnd # find / -name 'libGL.so' 2>/dev/null + # vulkan-loader + # vulkan-headers + # mesa_drivers + # linuxPackages.nvidia_x11 + # cudatoolkit + # cudatoolkit.lib + # mpi + + # + steam-run + + xorg.xclock + hello + sl + asciiquarium + figlet + cowsay + ponysay + cmatrix + + # Just enabling it is ok, and might be better + # nix + # nixVersions.nix_2_10 + + # pciutils # lspci and others + # coreboot-utils + + # # TODO: testar com o zsh + ## bashInteractive # https://www.reddit.com/r/NixOS/comments/zx4kmh/alpinewsl_home_manager_bash_issue/ + coreutils + binutils + utillinux + xorg.xkill + glibc.bin + patchelf + gparted + # glxinfo + file + findutils + gnugrep + gnumake + gnused + gawk + hexdump + which + xz + exfat + procps + curl + wget + lsof + tree + killall + nmap + netcat + tmate + strace + # ptrace + traceroute + man + man-db + (aspellWithDicts (d: with d; [ de en pt_BR ])) # nix repl --expr 'import {}' <<<'builtins.attrNames aspellDicts' | tr ' ' '\n' + gnome.simple-scan + imagemagick + nix-prefetch-git + nixfmt + hydra-check + nixos-option + shellcheck + + fontconfig + # fontforge-gtk # TODO: testar fontes usando esse programa + # pango + + # arphic-ukai + # arphic-uming + # aurulent-sans + # comic-relief + # corefonts # Microsoft free fonts + # dejavu_fonts + # dina-font + # fira # Monospace + # fira-code + # fira-code-symbols + # font-awesome # font-awesome-ttf, font-awesome_4 + # freefont_ttf + # hack-font + # hasklig + # inconsolata # Monospace + # ionicons + # lato + # liberation_ttf + # lineicons + # montserrat + # mplus-outline-fonts + nerdfonts # Really big, but only this font fixed some issues with starship + # noto-fonts + # noto-fonts-emoji + # noto-fonts-extra + powerline + powerline-fonts + # source-han-sans-japanese + # source-han-sans-korean + # source-han-sans-simplified-chinese + # source-han-sans-traditional-chinese + # source-sans + # source-sans-pro + # sudo-font + # symbola + # twemoji-color-font + # ubuntu_font_family + # unifont # International languages + # wqy_microhei + # wqy_zenhei + # xkcd-font + + # (nerdfonts.override { fonts = [ "FiraCode"]; }) + # ( + # nerdfonts.override { + # fonts = [ + # "AnonymousPro" + # "DroidSansMono" + # "FiraCode" + # "JetBrainsMono" + # "Noto" + # "Terminus" + # "Hack" + # "Ubuntu" + # "UbuntuMono" + # ]; + # } + # ) + + # zsh-nix-shell + # zsh-powerlevel10k + # zsh-powerlevel9k + # zsh-syntax-highlighting + + oh-my-zsh + # zsh-completions-latest + + # gcc + # gdb + # clang + # rustc + # python3Full + # julia-bin + + graphviz # dot command comes from here + jq + unixtools.xxd + + gzip + # unrar + unzip + gnutar + + btop + htop + asciinema + git + openssh + # sshfs # TODO: testar + + # #podman + # runc + # skopeo + # conmon + # slirp4netns + # shadow + + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "${HOME}"/.ssh/id_ed25519 \ + -N '' \ + && echo \ + && cat "${HOME}"/.ssh/id_ed25519.pub \ + && echo + '' + ) + + ( + writeScriptBin "gphms" '' + #! ${pkgs.runtimeShell} -e + + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + #! ${pkgs.runtimeShell} -e + nix repl --expr 'import {}' + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) + + ( + writeScriptBin "gphms" '' + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + nix repl --expr 'import {}' + '' + ) + ]; + + # https://github.com/nix-community/home-manager/blob/782cb855b2f23c485011a196c593e2d7e4fce746/modules/targets/generic-linux.nix + targets.genericLinux.enable = true; + + nix = { + enable = true; + # What about github:NixOS/nix#nix-static can it be injected here? What would break? + # package = pkgs.pkgsStatic.nixVersions.nix_2_10; + package = pkgs.nixVersions.nix_2_10; + # Could be useful: + # export NIX_CONFIG='extra-experimental-features = nix-command flakes' + extraOptions = '' + experimental-features = nix-command flakes + ''; + + settings = { + # use-sandbox = true; + show-trace = true; + # system-features = [ "big-parallel" "kvm" "recursive-nix" "nixos-test" ]; + keep-outputs = true; + keep-derivations = true; + + tarball-ttl = 60 * 60 * 24 * 7 * 4; # = 2419200 = one month + # readOnlyStore = true; + + # trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + # trusted-substituters = "fooooo"; + }; + }; + + nixpkgs.config = { + allowBroken = false; + allowUnfree = true; + # TODO: test it + # android_sdk.accept_license = true; + }; + + services.systembus-notify.enable = true; + services.spotifyd.enable = true; + + fonts = { + # enableFontDir = true; + # enableGhostscriptFonts = true; + # fonts = with pkgs; [ + # powerline-fonts + # ]; + fontconfig = { + enable = true; + # defaultFonts = { + # monospace = [ "Droid Sans Mono Slashed for Powerline" ]; + # }; + }; + }; + + programs.bash = { + enable = false; + # bashrcExtra = "echo foo-bar"; + sessionVariables = { + A_B_C = "a-b-c"; + FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; + }; + }; + + # TODO: documentar e testar + home.extraOutputsToInstall = [ + "/share/zsh" + "/share/bash" + "/share/fish" + "/share/fonts" # fc-cache -frv + # /etc/fonts + ]; + + # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ + programs.zsh = { + # Your zsh config + enable = true; + enableCompletion = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + envExtra = '' + if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then + . ~/.nix-profile/etc/profile.d/nix.sh + fi + ''; + + # initExtra = "neofetch --ascii_distro NixOS_small --color_blocks off --disable cpu gpu memory term de resolution kernel model"; + initExtra = "${pkgs.neofetch}/bin/neofetch"; # TODO: checar se esse pacote é seguro + + # promptInit = '' + # export POWERLEVEL9K_MODE=nerdfont-complete + # source ${pkgs.zsh-powerlevel9k}/share/zsh-powerlevel9k/powerlevel9k.zsh-theme + # ''; + + # initExtraBeforeCompInit = ''eval "$(direnv hook zsh)"''; + autocd = true; + + + shellAliases = { + l = "ls -al"; + + # + nb = "nix build"; + npi = "nix profile install nixpkgs#"; + ns = "nix shell"; + nr = "nix repl --expr 'import {}'"; + }; + + # > closed and reopened the terminal. Then it worked. + # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 + sessionVariables = { + # EDITOR = "nvim"; + # DEFAULT_USER = "foo-bar"; + # ZSH_AUTOSUGGEST_USE_ASYNC="true"; + # ZSH_AUTOSUGGEST_MANUAL_REBIND="true"; + # PROMPT="|%F{153}%n@%m%f|%F{174}%1~%f> "; + + LANG = "en_US.utf8"; + # fc-match list + FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; + }; + + historySubstringSearch.enable = true; + + history = { + save = 50000; + size = 50000; + path = "$HOME/.cache/zsh_history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix + plugins = [ + # "autojump" + "aws" + # "cargo" + "catimg" + "colored-man-pages" + "colorize" + "command-not-found" + "common-aliases" + "copyfile" + "copypath" + "cp" + "direnv" + "docker" + "docker-compose" + "emacs" + "encode64" + "extract" + "fancy-ctrl-z" + "fzf" + "gcloud" + "git" + "git-extras" + "git-flow-avh" + "github" + "gitignore" + "gradle" + "history" + "history-substring-search" + "kubectl" + "man" + "mvn" + "node" + "npm" + "pass" + "pip" + "poetry" + "python" + "ripgrep" + "rsync" + "rust" + "scala" + "ssh-agent" + "sudo" + "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin + "systemd" + "terraform" + # "thefuck" + "tig" + "timer" + # "tmux" # It needs tmux to be installed + "vagrant" + "vi-mode" + "vim-interaction" + "yarn" + "z" + "zsh-navigation-tools" + ]; + theme = "robbyrussell"; + # theme = "bira"; + # theme = "powerlevel10k"; + # theme = "powerlevel9k/powerlevel9k"; + # theme = "agnoster"; + # theme = "gallois"; + # theme = "gentoo"; + # theme = "af-magic"; + # theme = "half-life"; + # theme = "rgm"; + # theme = "crcandy"; + # theme = "fishy"; + }; + }; + + # programs.starship = { + # enable = true; + # enableZshIntegration = true; + # }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + # "$schema" = "https://starship.rs/config-schema.json"; + add_newline = true; + command_timeout = 500; + continuation_prompt = "[∙](bright-black) "; + # format = "[](0x9A348E)$username$hostname$localip$shlvl$singularity$kubernetes[](fg:0x9A348E bg:0xDA627D)$directory$vcsh[](fg:0xDA627D bg:0xFCA17D)$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch[](fg:0x86BBD8 bg:0x06969A)$docker_context$package$buf[](fg:0xFCA17D bg:0x86BBD8)$c$cmake$cobol$container$daml$dart$deno$dotnet$elixir$elm$erlang$golang$haskell$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$nix_shell$conda$spack$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery[](fg:0x06969A bg:0x33658A)$time$status$shell$character"; + right_format = ""; + scan_timeout = 30; + aws = { + format = "[$symbol($profile )(($region) )([$duration] )]($style)"; + symbol = "🅰 "; + style = "bold yellow"; + disabled = false; + expiration_symbol = "X"; + force_display = false; + }; + aws.region_aliases = {}; + aws.profile_aliases = {}; + azure = { + format = "[$symbol($subscription)([$duration])]($style) "; + symbol = "ﴃ "; + style = "blue bold"; + disabled = true; + }; + battery = { + format = "[$symbol$percentage]($style) "; + charging_symbol = " "; + discharging_symbol = " "; + empty_symbol = " "; + full_symbol = " "; + unknown_symbol = " "; + disabled = false; + display = [ + { + style = "red bold"; + threshold = 10; + } + ]; + }; + buf = { + format = "[$symbol ($version)]($style)"; + version_format = "v$raw"; + symbol = ""; + style = "bold blue"; + disabled = false; + detect_extensions = []; + detect_files = [ + "buf.yaml" + "buf.gen.yaml" + "buf.work.yaml" + ]; + detect_folders = []; + }; + c = { + format = "[$symbol($version(-$name) )]($style)"; + version_format = "v$raw"; + style = "fg:149 bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ + "c" + "h" + ]; + detect_files = []; + detect_folders = []; +# commands = [ +# [ +# "cc" +# "--version" +# ] +# [ +# "gcc" +# "--version" +# ] +# [ +# "clang" +# "--version" +# ] +# ]; + }; + character = { + format = "$symbol "; + vicmd_symbol = "[❮](bold green)"; + disabled = false; + success_symbol = "[➜](bold green) "; + error_symbol = "[✗](bold red) "; + }; + cmake = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "△ "; + style = "bold blue"; + disabled = false; + detect_extensions = []; + detect_files = [ + "CMakeLists.txt" + "CMakeCache.txt" + ]; + detect_folders = []; + }; + cmd_duration = { + min_time = 2000; + format = "⏱ [$duration]($style) "; + style = "yellow bold"; + show_milliseconds = false; + disabled = false; + show_notifications = false; + min_time_to_notify = 45000; + }; + cobol = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⚙️ "; + style = "bold blue"; + disabled = false; + detect_extensions = [ + "cbl" + "cob" + "CBL" + "COB" + ]; + detect_files = []; + detect_folders = []; + }; + conda = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = " "; + style = "green bold"; + ignore_base = true; + disabled = false; + }; + container = { + format = "[$symbol [$name]]($style) "; + symbol = "⬢"; + style = "red bold dimmed"; + disabled = false; + }; + crystal = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔮 "; + style = "bold red"; + disabled = false; + detect_extensions = ["cr"]; + detect_files = ["shard.yml"]; + detect_folders = []; + }; + dart = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🎯 "; + style = "bold blue"; + disabled = false; + detect_extensions = ["dart"]; + detect_files = [ + "pubspec.yaml" + "pubspec.yml" + "pubspec.lock" + ]; + detect_folders = [".dart_tool"]; + }; + deno = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦕 "; + style = "green bold"; + disabled = false; + detect_extensions = []; + detect_files = [ + "deno.json" + "deno.jsonc" + "mod.ts" + "deps.ts" + "mod.js" + "deps.js" + ]; + detect_folders = []; + }; + directory = { + disabled = false; + fish_style_pwd_dir_length = 0; + format = "[$path]($style)[$read_only]($read_only_style) "; + home_symbol = "~"; + read_only = " "; + read_only_style = "red"; + repo_root_format = "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; + style = "cyan bold bg:0xDA627D"; + truncate_to_repo = true; + truncation_length = 3; + truncation_symbol = "…/"; + use_logical_path = true; + use_os_path_sep = true; + }; + directory.substitutions = { + # Here is how you can shorten some long paths by text replacement; + # similar to mapped_locations in Oh My Posh:; + "Documents" = " "; + "Downloads" = " "; + "Music" = " "; + "Pictures" = " "; + # Keep in mind that the order matters. For example:; + # "Important Documents" = "  "; + # will not be replaced, because "Documents" was already substituted before.; + # So either put "Important Documents" before "Documents" or use the substituted version:; + # "Important  " = "  "; + "Important " = " "; + }; + docker_context = { + format = "[$symbol$context]($style) "; + style = "blue bold bg:0x06969A"; + symbol = " "; + only_with_files = true; + disabled = false; + detect_extensions = []; + detect_files = [ + "docker-compose.yml" + "docker-compose.yaml" + "Dockerfile" + ]; + detect_folders = []; + }; + dotnet = { + format = "[$symbol($version )(🎯 $tfm )]($style)"; + version_format = "v$raw"; + symbol = "🥅 "; + style = "blue bold"; + heuristic = true; + disabled = false; + detect_extensions = [ + "csproj" + "fsproj" + "xproj" + ]; + detect_files = [ + "global.json" + "project.json" + "Directory.Build.props" + "Directory.Build.targets" + "Packages.props" + ]; + detect_folders = []; + }; + elixir = { + format = "[$symbol($version (OTP $otp_version) )]($style)"; + version_format = "v$raw"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = []; + detect_files = ["mix.exs"]; + detect_folders = []; + }; + elm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "cyan bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = ["elm"]; + detect_files = [ + "elm.json" + "elm-package.json" + ".elm-version" + ]; + detect_folders = ["elm-stuff"]; + }; + env_var = {}; + env_var.SHELL = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + variable = "SHELL"; + default = "unknown shell"; + }; + env_var.USER = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + default = "unknown user"; + }; + erlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold red"; + disabled = false; + detect_extensions = []; + detect_files = [ + "rebar.config" + "erlang.mk" + ]; + detect_folders = []; + }; + fill = { + style = "bold black"; + symbol = "."; + disabled = false; + }; + gcloud = { + format = "[$symbol$account(@$domain)(($region))(($project))]($style) "; + symbol = "☁️ "; + style = "bold blue"; + disabled = false; + }; + gcloud.project_aliases = {}; + gcloud.region_aliases = {}; + git_branch = { + format = "[$symbol$branch(:$remote_branch)]($style) "; + symbol = " "; + style = "bold purple bg:0xFCA17D"; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + only_attached = false; + always_show_remote = false; + ignore_branches = []; + disabled = false; + }; + git_commit = { + commit_hash_length = 7; + format = "[($hash$tag)]($style) "; + style = "green bold"; + only_detached = true; + disabled = false; + tag_symbol = " 🏷 "; + tag_disabled = true; + }; + git_metrics = { + added_style = "bold green"; + deleted_style = "bold red"; + only_nonzero_diffs = true; + format = "([+$added]($added_style) )([-$deleted]($deleted_style) )"; + disabled = false; + }; + git_state = { + am = "AM"; + am_or_rebase = "AM/REBASE"; + bisect = "BISECTING"; + cherry_pick = "🍒PICKING(bold red)"; + disabled = false; + format = "([$state( $progress_current/$progress_total)]($style)) "; + merge = "MERGING"; + rebase = "REBASING"; + revert = "REVERTING"; + style = "bold yellow"; + }; + git_status = { + ahead = "🏎💨$count"; + behind = "😰$count"; + conflicted = "🏳"; + deleted = "🗑"; + disabled = false; + diverged = "😵"; + # format = "([[$all_status$ahead_behind]]($style) )"; + ignore_submodules = false; + modified = "📝"; + renamed = "👅"; + staged = "[++($count)](green)"; + stashed = "📦"; + style = "red bold bg:0xFCA17D"; + untracked = "🤷"; + up_to_date = "✓"; + }; + golang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold cyan bg:0x86BBD8"; + disabled = false; + detect_extensions = ["go"]; + detect_files = [ + "go.mod" + "go.sum" + "glide.yaml" + "Gopkg.yml" + "Gopkg.lock" + ".go-version" + ]; + detect_folders = ["Godeps"]; + }; + haskell = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "λ "; + style = "bold purple bg:0x86BBD8"; + disabled = false; + detect_extensions = [ + "hs" + "cabal" + "hs-boot" + ]; + detect_files = [ + "stack.yaml" + "cabal.project" + ]; + detect_folders = []; + }; + helm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⎈ "; + style = "bold white"; + disabled = false; + detect_extensions = []; + detect_files = [ + "helmfile.yaml" + "Chart.yaml" + ]; + detect_folders = []; + }; + hg_branch = { + symbol = " "; + style = "bold purple"; + format = "on [$symbol$branch]($style) "; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + disabled = true; + }; + hostname = { + disabled = false; + format = "[$ssh_symbol](blue dimmed bold)[$hostname]($style) "; + ssh_only = false; + style = "green dimmed bold"; + trim_at = "."; + }; + java = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "red dimmed bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = [ + "java" + "class" + "jar" + "gradle" + "clj" + "cljc" + ]; + detect_files = [ + "pom.xml" + "build.gradle.kts" + "build.sbt" + ".java-version" + "deps.edn" + "project.clj" + "build.boot" + ]; + detect_folders = []; + }; + jobs = { + threshold = 1; + symbol_threshold = 0; + number_threshold = 2; + format = "[$symbol$number]($style) "; + symbol = "✦"; + style = "bold blue"; + disabled = false; + }; + julia = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = ["jl"]; + detect_files = [ + "Project.toml" + "Manifest.toml" + ]; + detect_folders = []; + }; + kotlin = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🅺 "; + style = "bold blue"; + kotlin_binary = "kotlin"; + disabled = false; + detect_extensions = [ + "kt" + "kts" + ]; + detect_files = []; + detect_folders = []; + }; + kubernetes = { + disabled = false; + format = "[$symbol$context( ($namespace))]($style) in "; + style = "cyan bold"; + symbol = "⛵ "; + }; + kubernetes.context_aliases = {}; + line_break = { + disabled = false; + }; + localip = { + disabled = false; + format = "[@$localipv4]($style) "; + ssh_only = false; + style = "yellow bold"; + }; + lua = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🌙 "; + style = "bold blue"; + lua_binary = "lua"; + disabled = false; + detect_extensions = ["lua"]; + detect_files = [".lua-version"]; + detect_folders = ["lua"]; + }; + memory_usage = { + disabled = false; + format = "$symbol[$ram( | $swap)]($style) "; + style = "white bold dimmed"; + symbol = " "; + # threshold = 75; + threshold = -1; + }; + nim = { + format = "[$symbol($version )]($style)"; + style = "yellow bold bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "nim" + "nims" + "nimble" + ]; + detect_files = ["nim.cfg"]; + detect_folders = []; + }; + nix_shell = { + format = "[$symbol$state( ($name))]($style) "; + disabled = false; + impure_msg = "[impure](bold red)"; + pure_msg = "[pure](bold green)"; + style = "bold blue"; + symbol = " "; + }; + nodejs = { + format = "[$symbol($version )]($style)"; + not_capable_style = "bold red"; + style = "bold green bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "js" + "mjs" + "cjs" + "ts" + "mts" + "cts" + ]; + detect_files = [ + "package.json" + ".node-version" + ".nvmrc" + ]; + detect_folders = ["node_modules"]; + }; + ocaml = { + format = "[$symbol($version )(($switch_indicator$switch_name) )]($style)"; + global_switch_indicator = ""; + local_switch_indicator = "*"; + style = "bold yellow"; + symbol = "🐫 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "opam" + "ml" + "mli" + "re" + "rei" + ]; + detect_files = [ + "dune" + "dune-project" + "jbuild" + "jbuild-ignore" + ".merlin" + ]; + detect_folders = [ + "_opam" + "esy.lock" + ]; + }; + openstack = { + format = "[$symbol$cloud(($project))]($style) "; + symbol = "☁️ "; + style = "bold yellow"; + disabled = false; + }; + package = { + format = "[$symbol$version]($style) "; + symbol = "📦 "; + style = "208 bold"; + display_private = false; + disabled = false; + version_format = "v$raw"; + }; + perl = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐪 "; + style = "149 bold"; + disabled = false; + detect_extensions = [ + "pl" + "pm" + "pod" + ]; + detect_files = [ + "Makefile.PL" + "Build.PL" + "cpanfile" + "cpanfile.snapshot" + "META.json" + "META.yml" + ".perl-version" + ]; + detect_folders = []; + }; + php = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐘 "; + style = "147 bold"; + disabled = false; + detect_extensions = ["php"]; + detect_files = [ + "composer.json" + ".php-version" + ]; + detect_folders = []; + }; + pulumi = { + format = "[$symbol($username@)$stack]($style) "; + version_format = "v$raw"; + symbol = " "; + style = "bold 5"; + disabled = false; + }; + purescript = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "<=> "; + style = "bold white"; + disabled = false; + detect_extensions = ["purs"]; + detect_files = ["spago.dhall"]; + detect_folders = []; + }; + python = { + format = "[$symbol$pyenv_prefix($version )(($virtualenv) )]($style)"; + python_binary = [ + "python" + "python3" + "python2" + ]; + pyenv_prefix = "pyenv "; + pyenv_version_name = true; + style = "yellow bold"; + symbol = "🐍 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = ["py"]; + detect_files = [ + "requirements.txt" + ".python-version" + "pyproject.toml" + "Pipfile" + "tox.ini" + "setup.py" + "__init__.py" + ]; + detect_folders = []; + }; + red = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔺 "; + style = "red bold"; + disabled = false; + detect_extensions = [ + "red" + "reds" + ]; + detect_files = []; + detect_folders = []; + }; + rlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "blue bold"; + symbol = "📐 "; + disabled = false; + detect_extensions = [ + "R" + "Rd" + "Rmd" + "Rproj" + "Rsx" + ]; + detect_files = [".Rprofile"]; + detect_folders = [".Rproj.user"]; + }; + ruby = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "💎 "; + style = "bold red"; + disabled = false; + detect_extensions = ["rb"]; + detect_files = [ + "Gemfile" + ".ruby-version" + ]; + detect_folders = []; + detect_variables = [ + "RUBY_VERSION" + "RBENV_VERSION" + ]; + }; + rust = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦀 "; + style = "bold red bg:0x86BBD8"; + disabled = false; + detect_extensions = ["rs"]; + detect_files = ["Cargo.toml"]; + detect_folders = []; + }; + scala = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + disabled = false; + style = "red bold"; + symbol = "🆂 "; + detect_extensions = [ + "sbt" + "scala" + ]; + detect_files = [ + ".scalaenv" + ".sbtenv" + "build.sbt" + ]; + detect_folders = [".metals"]; + }; + shell = { + format = "[$indicator]($style) "; + bash_indicator = "bsh"; + cmd_indicator = "cmd"; + elvish_indicator = "esh"; + fish_indicator = ""; + ion_indicator = "ion"; + nu_indicator = "nu"; + powershell_indicator = "_"; + style = "white bold"; + tcsh_indicator = "tsh"; + unknown_indicator = "mystery shell"; + xonsh_indicator = "xsh"; + zsh_indicator = "zsh"; + disabled = false; + }; + shlvl = { + threshold = 2; + format = "[$symbol$shlvl]($style) "; + symbol = "↕️ "; + repeat = false; + style = "bold yellow"; + disabled = true; + }; + singularity = { + format = "[$symbol[$env]]($style) "; + style = "blue bold dimmed"; + symbol = "📦 "; + disabled = false; + }; + spack = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = "🅢 "; + style = "blue bold"; + disabled = false; + }; + status = { + format = "[$symbol$status]($style) "; + map_symbol = true; + not_executable_symbol = "🚫"; + not_found_symbol = "🔍"; + pipestatus = false; + pipestatus_format = "[$pipestatus] => [$symbol$common_meaning$signal_name$maybe_int]($style)"; + pipestatus_separator = "|"; + recognize_signal_code = true; + signal_symbol = "⚡"; + style = "bold red bg:blue"; + success_symbol = "🟢 SUCCESS"; + symbol = "🔴 "; + disabled = true; + }; + sudo = { + format = "[as $symbol]($style)"; + symbol = "🧙 "; + style = "bold blue"; + allow_windows = false; + disabled = true; + }; + swift = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐦 "; + style = "bold 202"; + disabled = false; + detect_extensions = ["swift"]; + detect_files = ["Package.swift"]; + detect_folders = []; + }; + terraform = { + format = "[$symbol$workspace]($style) "; + version_format = "v$raw"; + symbol = "💠 "; + style = "bold 105"; + disabled = false; + detect_extensions = [ + "tf" + "tfplan" + "tfstate" + ]; + detect_files = []; + detect_folders = [".terraform"]; + }; + time = { + format = "[$symbol $time]($style) "; + style = "bold yellow bg:0x33658A"; + use_12hr = false; + disabled = false; + utc_time_offset = "local"; + # time_format = "%R"; # Hour:Minute Format; + time_format = "%T"; # Hour:Minute:Seconds Format; + time_range = "-"; + }; + username = { + format = "[$user]($style) "; + show_always = true; + style_root = "red bold bg:0x9A348E"; + style_user = "yellow bold bg:0x9A348E"; + disabled = false; + }; + vagrant = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⍱ "; + style = "cyan bold"; + disabled = false; + detect_extensions = []; + detect_files = ["Vagrantfile"]; + detect_folders = []; + }; + vcsh = { + symbol = ""; + style = "bold yellow"; + format = "[$symbol$repo]($style) "; + disabled = false; + }; + vlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "V "; + style = "blue bold"; + disabled = false; + detect_extensions = ["v"]; + detect_files = [ + "v.mod" + "vpkg.json" + ".vpkg-lock.json" + ]; + detect_folders = []; + }; + zig = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "↯ "; + style = "bold yellow"; + disabled = false; + detect_extensions = ["zig"]; + detect_files = []; + detect_folders = []; + }; + custom = { + }; + }; + }; + + # https://nix-community.github.io/home-manager/options.html#opt-programs.direnv.config + programs.direnv = { + enable = true; + nix-direnv = { + enable = true; + }; + enableZshIntegration = true; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + # enableBashIntegration = true; + # enableFishIntegration = true; + }; + + # This makes it so that if you type the name of a program that + # isn't installed, it will tell you which package contains it. + # https://eevie.ro/posts/2022-01-24-how-i-nix.html + # + programs.nix-index = { + enable = true; + # enableFishIntegration = true; + # enableBashIntegration = true; + enableZshIntegration = true; + }; + + programs.home-manager = { + enable = true; + }; +} From 661975fa08e58c1fa3f175fa90899db540cbcffd Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 23:41:25 -0300 Subject: [PATCH 007/191] =?UTF-8?q?Teste=20de=20template,=20adiciona=20ins?= =?UTF-8?q?tala=C3=A7=C3=A3o=20do=20nix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/profile/README.md b/profile/README.md index b118712..0e75374 100644 --- a/profile/README.md +++ b/profile/README.md @@ -9,6 +9,13 @@ command -v curl || (command -v apt && sudo apt-get update && sudo apt-get instal command -v curl || (command -v apk && sudo apk add --no-cache -y curl) +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ +&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh + +export NIX_CONFIG='extra-experimental-features = nix-command flakes' + + # Precisa das variáveis de ambiente USER e HOME DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs From be0aaeede0f5fba52b75c96ae260f0202d35595c Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 23:44:05 -0300 Subject: [PATCH 008/191] Teste de template, fix } --- profile/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/profile/README.md b/profile/README.md index 0e75374..76b7b18 100644 --- a/profile/README.md +++ b/profile/README.md @@ -21,9 +21,10 @@ DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs nix \ shell \ -github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#coreutils} \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#coreutils \ --command \ bash <<-EOF + echo $DIRETORY_TO_CLONE mkdir -pv $DIRETORY_TO_CLONE EOF @@ -58,17 +59,17 @@ export NIXPKGS_ALLOW_UNFREE=1 \ # TARGET_SHELL='zsh' \ -&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ +&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ && echo \ -&& ls -al "\$FULL_TARGET_SHELL" \ +&& ls -al "$FULL_TARGET_SHELL" \ && echo \ -&& echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ +&& echo "$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ && echo \ && sudo \ -k \ usermod \ -s \ - /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + /home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ "$USER" EOF ``` From 31d83131c0244683fbdc494b9e66ebcfdf9b25ec Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 23:48:33 -0300 Subject: [PATCH 009/191] Teste de template, fix nome da branch --- profile/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 76b7b18..f459ce7 100644 --- a/profile/README.md +++ b/profile/README.md @@ -34,7 +34,7 @@ nix \ flake \ init \ --template \ -github:PedroRegisPOAR/.github#start-config-graphical-full +github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#start-config-graphical-full nix \ From 37ac7a51abaab1788e7d218f180f4d7685fe32ea Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 9 Mar 2023 23:53:30 -0300 Subject: [PATCH 010/191] Teste de template, hardcode system como x86_64-linux --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index aa0c6c4..5a56e9f 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,8 @@ name = "imobanco-entrypoint"; pkgsAllowUnfree = import nixpkgs { - inherit system; + # inherit system; + system = "x86_64-linux"; config = { allowUnfree = true; }; }; From d1eb5390b99b4e94210771ecce29eac1b91dbbcb Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 00:02:34 -0300 Subject: [PATCH 011/191] Teste de template, refactor --- profile/README.md | 88 ++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/profile/README.md b/profile/README.md index f459ce7..49461af 100644 --- a/profile/README.md +++ b/profile/README.md @@ -4,6 +4,7 @@ ## Template + ```bash command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) command -v curl || (command -v apk && sudo apk add --no-cache -y curl) @@ -17,60 +18,53 @@ export NIX_CONFIG='extra-experimental-features = nix-command flakes' # Precisa das variáveis de ambiente USER e HOME -DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs - -nix \ -shell \ -github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#coreutils \ ---command \ -bash <<-EOF - echo $DIRETORY_TO_CLONE - mkdir -pv $DIRETORY_TO_CLONE -EOF - -cd $DIRETORY_TO_CLONE - -nix \ -flake \ -init \ ---template \ -github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#start-config-graphical-full +DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs nix \ shell \ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ --command \ bash <<-EOF - -sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ -&& git init \ -&& git status \ -&& git add . \ -&& nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ -&& git status \ -&& git add . - - -export NIXPKGS_ALLOW_UNFREE=1 \ -&& home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ -&& home-manager generations - - -# -TARGET_SHELL='zsh' \ -&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ -&& echo \ -&& ls -al "$FULL_TARGET_SHELL" \ -&& echo \ -&& echo "$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ -&& echo \ -&& sudo \ - -k \ - usermod \ - -s \ - /home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ - "$USER" + echo $DIRETORY_TO_CLONE + mkdir -pv $DIRETORY_TO_CLONE + + cd $DIRETORY_TO_CLONE + + nix \ + flake \ + init \ + --template \ + github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#templates.x86_64-linux.baseStartConfigGraphicalFull + + sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ + && git init \ + && git status \ + && git add . \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && git status \ + && git add . + + + export NIXPKGS_ALLOW_UNFREE=1 \ + && home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ + && home-manager generations + + + # + TARGET_SHELL='zsh' \ + && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ + && echo \ + && ls -al "$FULL_TARGET_SHELL" \ + && echo \ + && echo "$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ + && echo \ + && sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ + "$USER" EOF ``` From 89120764103fa7e90234d3202e7a8f71dfb118b5 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 00:06:36 -0300 Subject: [PATCH 012/191] Teste de template, fix conflito de sintaxe bash vs nix --- profile/README.md | 2 +- templates/start-config-graphical-full/home.nix | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/profile/README.md b/profile/README.md index 49461af..62295b7 100644 --- a/profile/README.md +++ b/profile/README.md @@ -47,7 +47,7 @@ bash <<-EOF export NIXPKGS_ALLOW_UNFREE=1 \ - && home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ + && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs \ && home-manager generations diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 4adf987..81cbd3e 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -242,10 +242,10 @@ ssh-keygen \ -t ed25519 \ -C "$(git config user.email)" \ - -f "${HOME}"/.ssh/id_ed25519 \ - -N '' \ + -f "$HOME"/.ssh/id_ed25519 \ + -N "" \ && echo \ - && cat "${HOME}"/.ssh/id_ed25519.pub \ + && cat "$HOME"/.ssh/id_ed25519.pub \ && echo '' ) From f2e589a00c7663a540a7edf04224e5a2215b4ec7 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 10:26:22 -0300 Subject: [PATCH 013/191] Teste de template, fix conflito de multiplos gphms --- templates/start-config-graphical-full/home.nix | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 81cbd3e..28c8723 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -250,16 +250,6 @@ '' ) - ( - writeScriptBin "gphms" '' - #! ${pkgs.runtimeShell} -e - - echo $(cd "$HOME/.config/nixpkgs" && git pull) \ - && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" - '' - ) - ( writeScriptBin "nr" '' #! ${pkgs.runtimeShell} -e From 31fe23d9cc7749a6542b415ddef05782496b4138 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 11:55:43 -0300 Subject: [PATCH 014/191] Teste de template, fix nr --- templates/start-config-graphical-full/home.nix | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 28c8723..a60bc40 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -250,13 +250,6 @@ '' ) - ( - writeScriptBin "nr" '' - #! ${pkgs.runtimeShell} -e - nix repl --expr 'import {}' - '' - ) - ( writeScriptBin "nfm" '' #! ${pkgs.runtimeShell} -e @@ -384,7 +377,7 @@ nb = "nix build"; npi = "nix profile install nixpkgs#"; ns = "nix shell"; - nr = "nix repl --expr 'import {}'"; + # nr = "nix repl --expr 'import {}'"; }; # > closed and reopened the terminal. Then it worked. From bc03e18ad7dae81ab7a2fe67d67e111a8c260789 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 13:41:20 -0300 Subject: [PATCH 015/191] Teste de template, fix remove \ de escape --- templates/start-config-graphical-full/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-config-graphical-full/flake.nix b/templates/start-config-graphical-full/flake.nix index 440e87f..13ff47d 100644 --- a/templates/start-config-graphical-full/flake.nix +++ b/templates/start-config-graphical-full/flake.nix @@ -20,7 +20,7 @@ { home = { inherit username; - homeDirectory = "/home/\${username}"; # TODO: esse caminho muda no Mac! + homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! stateVersion = "22.11"; }; programs.home-manager.enable = true; From de30b25b5999ac7f9673d461a1b2e7e71d65bbff Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 15:08:29 -0300 Subject: [PATCH 016/191] =?UTF-8?q?Teste=20de=20template,=20fix=20adiciona?= =?UTF-8?q?=20\=20para=20escape=20na=20vari=C3=A1vel=20$TARGET=5FSHELL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/profile/README.md b/profile/README.md index 62295b7..4328df7 100644 --- a/profile/README.md +++ b/profile/README.md @@ -53,17 +53,17 @@ bash <<-EOF # TARGET_SHELL='zsh' \ - && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ + && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ && echo \ - && ls -al "$FULL_TARGET_SHELL" \ + && ls -al "\$FULL_TARGET_SHELL" \ && echo \ - && echo "$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ + && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ && echo \ && sudo \ -k \ usermod \ -s \ - /home/"$USER"/.nix-profile/bin/"$TARGET_SHELL" \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ "$USER" EOF ``` From d44840dce5e0043e712561082db0786f7d15fbb9 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 15:26:37 -0300 Subject: [PATCH 017/191] Teste de template, documenta passos --- profile/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 4328df7..e9aeb93 100644 --- a/profile/README.md +++ b/profile/README.md @@ -4,7 +4,7 @@ ## Template - +1) ```bash command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) command -v curl || (command -v apk && sudo apk add --no-cache -y curl) @@ -68,7 +68,17 @@ bash <<-EOF EOF ``` +2) +```bash +sudo reboot +``` + +3) Adicionando uma nova cahve ssh a sua conta do github: +https://github.com/settings/ssh/new + +4) Ir para o repositório privado do Imobanco? +https://github.com/imobanco/.config-nixpkgs ## Slim, home-manager + nix + zsh + fonts From a38d8661b50e1958fefe6bc147140abeca4fee1a Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 15:47:48 -0300 Subject: [PATCH 018/191] Remove outras tentativas --- profile/README.md | 586 ---------------------------------------------- 1 file changed, 586 deletions(-) diff --git a/profile/README.md b/profile/README.md index e9aeb93..48ac9ee 100644 --- a/profile/README.md +++ b/profile/README.md @@ -80,589 +80,3 @@ https://github.com/settings/ssh/new 4) Ir para o repositório privado do Imobanco? https://github.com/imobanco/.config-nixpkgs -## Slim, home-manager + nix + zsh + fonts - - -```bash -command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) -command -v curl || (command -v apk && sudo apk add --no-cache -y curl) - -NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ -&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh - -export NIX_CONFIG='extra-experimental-features = nix-command flakes' - -nix \ -shell \ -github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ ---command \ -bash <<-EOF - - echo $PATH | tr ':' '\n' - - { - mkdir -pv /home/"$USER"/.config/nixpkgs \ - && ls -al /home/"$USER"/.config/nixpkgs \ - && tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' - { pkgs, ... }: - - { - - home.packages = with pkgs; [ - btop - coreutils - curl - git - jq - neovim - openssh - shadow - tmate - zsh - - ( - writeScriptBin "ix" '' - "$@" | "curl" -F 'f:1=<-' ix.io - '' - ) - - ( - writeScriptBin "gphms" '' - echo $(cd "$HOME/.config/nixpkgs" && git pull) \ - && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" - '' - ) - - ( - writeScriptBin "nr" '' - nix repl --expr 'import {}' - '' - ) - - ( - writeScriptBin "nfm" '' - #! \${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) - - ]; - - nix = { - enable = true; - package = pkgs.nixVersions.nix_2_10; - extraOptions = "experimental-features = nix-command flakes"; - }; - - # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ - programs.zsh = { - # Your zsh config - enable = true; - enableCompletion = true; - dotDir = ".config/zsh"; - enableAutosuggestions = true; - enableSyntaxHighlighting = true; - envExtra = '' - if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then - . ~/.nix-profile/etc/profile.d/nix.sh - fi - ''; - - # > closed and reopened the terminal. Then it worked. - # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 - sessionVariables = { - LANG = "en_US.utf8"; - }; - - historySubstringSearch.enable = true; - - history = { - save = 50000; - size = 50000; - path = "$HOME/.cache/zsh_history"; - expireDuplicatesFirst = true; - }; - - oh-my-zsh = { - enable = true; - # plugins = (import ./zsh/plugins.nix) pkgs; - # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix - plugins = [ - "colored-man-pages" - "colorize" - "fzf" - "git" - "git-extras" - "github" - "gitignore" - "history" - "history-substring-search" - "man" - "ssh-agent" - "sudo" - "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin - "zsh-navigation-tools" - ]; - theme = "robbyrussell"; - }; - }; - - programs.fzf = { - enable = true; - enableZshIntegration = true; - }; - - programs.starship = { - enable = true; - enableZshIntegration = true; - settings = { - shell = { disabled = false; }; - rlang = { detect_files = [ ]; }; - python = { disabled = true; }; - }; - }; - - programs.home-manager = { - enable = true; - }; - } -NESTEDEOF - - -tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' - { - description = "Home Manager configuration"; - - inputs = { - # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; - - outputs = { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - username = "vagrant"; - in { - homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.\${system}; - - modules = [ - { - home = { - inherit username; - # TODO: esse caminho muda no Mac! - homeDirectory = "/home/\${username}"; - stateVersion = "22.11"; - }; - programs.home-manager.enable = true; - } - ./home.nix - ]; - - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; - }; - } -NESTEDEOF -} && echo 1234 \ -&& cd /home/"$USER"/.config/nixpkgs/ \ -&& echo 5678 \ -&& sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ -&& git init \ -&& git status \ -&& git add . \ -&& nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ -&& git status \ -&& git add . - -# Estas linhas precisam das variáveis de ambiente USER e HOME -export NIXPKGS_ALLOW_UNFREE=1 \ -&& home-manager switch -b backuphm --impure --flake ~/.config/nixpkgs \ -&& home-manager generations - - -# -TARGET_SHELL='zsh' \ -&& FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ -&& echo \ -&& ls -al "\$FULL_TARGET_SHELL" \ -&& echo \ -&& echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ -&& echo \ -&& sudo \ - -k \ - usermod \ - -s \ - /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - "$USER" -EOF - -# sudo reboot - -``` - - - -## Broken - - -```bash -command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) -command -v curl || (command -v apk && sudo apk add --no-cache -y curl) - -NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ -&& . "$HOME"/.nix-profile/etc/profile.d/nix.sh - -export NIX_CONFIG='extra-experimental-features = nix-command flakes' - -nix \ -shell \ -github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ ---command \ -bash <<-EOF -{ - - mkdir -pv /home/"$USER"/.config/nixpkgs \ - && ls -al /home/"$USER"/.config/nixpkgs - - tee /home/"$USER"/.config/nixpkgs/home.nix <<'NESTEDEOF' - { pkgs, ... }: - { - - home.packages = with pkgs; [ - btop - coreutils - curl - git - jq - neovim - openssh - shadow - tmate - zsh - - # - nerdfonts - - # Graphical -# 1password-gui -# discord -# gimp -# gitkraken -# google-chrome -# kolourpaint -# obsidian -# qbittorrent -# slack -# spotify -# tdesktop -# vscodium - - ( - writeScriptBin "ix" '' - #! ${pkgs.runtimeShell} -e - "$@" | "curl" -F 'f:1=<-' ix.io - '' - ) - ( - writeScriptBin "erw" '' - #! ${pkgs.runtimeShell} -e - echo "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "crw" '' - #! ${pkgs.runtimeShell} -e - cat "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "generate-new-ed25519-key-pair" '' - #! ${pkgs.runtimeShell} -e - ssh-keygen \ - -t ed25519 \ - -C "$(git config user.email)" \ - -f "${HOME}"/.ssh/id_ed25519 \ - -N '' \ - && echo \ - && cat "${HOME}"/.ssh/id_ed25519.pub \ - && echo - '' - ) - - ( - writeScriptBin "gphms" '' - #! ${pkgs.runtimeShell} -e - echo $(cd "$HOME/.config/nixpkgs" && git pull) \ - && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" - '' - ) - - ( - writeScriptBin "nr" '' - #! ${pkgs.runtimeShell} -e - nix repl --expr 'import {}' - '' - ) - - ( - writeScriptBin "nfm" '' - #! ${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) - ]; - - nix = { - enable = true; - package = pkgs.nixVersions.nix_2_10; - extraOptions = '' - experimental-features = nix-command flakes - ''; - - settings = { - # use-sandbox = true; - show-trace = false; - keep-outputs = true; - keep-derivations = true; - - # One month: 60 * 60 * 24 * 7 * 4 = 2419200 - tarball-ttl = 60 * 60 * 24 * 7 * 4; - }; - }; - - nixpkgs.config = { - allowBroken = false; - allowUnfree = true; - }; - - - fonts = { - fontconfig = { - enable = true; - }; - }; - - home.extraOutputsToInstall = [ - "/share/zsh" - "/share/bash" - "/share/fish" - "/share/fonts" # fc-cache -frv - # /etc/fonts - ]; - - # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ - programs.zsh = { - # Your zsh config - enable = true; - enableCompletion = true; - dotDir = ".config/zsh"; - enableAutosuggestions = true; - enableSyntaxHighlighting = true; - envExtra = '' - if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then - . ~/.nix-profile/etc/profile.d/nix.sh - fi - ''; - - initExtra = "${pkgs.neofetch}/bin/neofetch"; - autocd = true; - - # > closed and reopened the terminal. Then it worked. - # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 - sessionVariables = { - LANG = "en_US.utf8"; - # fc-match list - FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; - FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; - }; - - historySubstringSearch.enable = true; - - history = { - save = 50000; - size = 50000; - path = "$HOME/.cache/zsh_history"; - expireDuplicatesFirst = true; - }; - - oh-my-zsh = { - enable = true; - # plugins = (import ./zsh/plugins.nix) pkgs; - # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix - plugins = [ - # "autojump" - "aws" - # "cargo" - "catimg" - "colored-man-pages" - "colorize" - "command-not-found" - "common-aliases" - "copyfile" - "copypath" - "cp" - "direnv" - "docker" - "docker-compose" - "emacs" - "encode64" - "extract" - "fancy-ctrl-z" - "fzf" - "gcloud" - "git" - "git-extras" - "git-flow-avh" - "github" - "gitignore" - "gradle" - "history" - "history-substring-search" - "kubectl" - "man" - "mvn" - "node" - "npm" - "pass" - "pip" - "poetry" - "python" - "ripgrep" - "rsync" - "rust" - "scala" - "ssh-agent" - "sudo" - "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin - "systemd" - "terraform" - # "thefuck" - "tig" - "timer" - # "tmux" # It needs to be installed - "vagrant" - "vi-mode" - "vim-interaction" - "yarn" - "z" - "zsh-navigation-tools" - ]; - theme = "robbyrussell"; - # theme = "bira"; - # theme = "powerlevel10k"; - # theme = "powerlevel9k/powerlevel9k"; - # theme = "agnoster"; - # theme = "gallois"; - # theme = "gentoo"; - # theme = "af-magic"; - # theme = "half-life"; - # theme = "rgm"; - # theme = "crcandy"; - # theme = "fishy"; - }; - }; - - programs.fzf = { - enable = true; - enableZshIntegration = true; - }; - - programs.starship = { - enable = true; - enableZshIntegration = true; - settings = { - shell = { disabled = false; }; - rlang = { detect_files = [ ]; }; - python = { disabled = true; }; - }; - }; - - programs.home-manager = { - enable = true; - }; - } -NESTEDEOF - - -tee /home/"$USER"/.config/nixpkgs/flake.nix <<'NESTEDEOF' - { - description = "Home Manager configuration"; - - inputs = { - # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; - - outputs = { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - username = "vagrant"; - in { - homeConfigurations.\${username} = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.\${system}; - - modules = [ - { - home = { - inherit username; - # TODO: esse caminho muda no Mac! - homeDirectory = "/home/\${username}"; - stateVersion = "22.11"; - }; - programs.home-manager.enable = true; - } - ./home.nix - ]; - - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; - }; - } -NESTEDEOF - - echo \ - && cd /home/"$USER"/.config/nixpkgs/ \ - && sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ - && git init \ - && git status \ - && git add . \ - && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ - && git status \ - && git add . - - # Estas linhas precisam das variáveis de ambiente USER e HOME - export NIXPKGS_ALLOW_UNFREE=1 \ - && home-manager switch -b backuphm --impure --flake "$HOME"/.config/nixpkgs \ - && home-manager generations - - # - TARGET_SHELL='zsh' \ - && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - && echo \ - && ls -al "\$FULL_TARGET_SHELL" \ - && echo \ - && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ - && echo \ - && sudo \ - -k \ - usermod \ - -s \ - /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - "$USER" -EOF - -# sudo reboot -``` From 73d66dd5e26bc259dcec40ceb4d7c94d24889930 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 15:49:09 -0300 Subject: [PATCH 019/191] =?UTF-8?q?Adds=20links=20de=20cr=C3=A9ditos=20pel?= =?UTF-8?q?o=20boilerplate=20do=20starship?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/start-config-graphical-full/home.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index a60bc40..9485237 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -485,6 +485,9 @@ # enableZshIntegration = true; # }; + # Credits: + # https://gist.github.com/s-a-c/0e44dc7766922308924812d4c019b109 + # https://gist.github.com/search?q=So+either+put+%22Important+Documents%22+before+%22Documents%22+or+use+the+substituted+version%3A%3B&ref=searchresults programs.starship = { enable = true; enableZshIntegration = true; From 7e61269ce9bb1e740132eadd53a8d49186dc6994 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 16:31:16 -0300 Subject: [PATCH 020/191] =?UTF-8?q?Adds=20template=20sem=20interface=20gr?= =?UTF-8?q?=C3=A1fica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 2 +- templates/default.nix | 5 + templates/start-config/flake.nix | 35 + templates/start-config/home.nix | 1427 ++++++++++++++++++++++++++++++ 4 files changed, 1468 insertions(+), 1 deletion(-) create mode 100644 templates/start-config/flake.nix create mode 100644 templates/start-config/home.nix diff --git a/profile/README.md b/profile/README.md index 48ac9ee..6b6f858 100644 --- a/profile/README.md +++ b/profile/README.md @@ -73,7 +73,7 @@ EOF sudo reboot ``` -3) Adicionando uma nova cahve ssh a sua conta do github: +3) Adicionando uma nova chave ssh a sua conta do github: https://github.com/settings/ssh/new diff --git a/templates/default.nix b/templates/default.nix index 564416e..d9e3576 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -3,4 +3,9 @@ description = "Configuração base inicial COM insterface gráfica"; path = ./start-config-graphical-full; }; + + startConfig = { + description = "Configuração base inicial COM insterface gráfica"; + path = ./start-config; + }; } diff --git a/templates/start-config/flake.nix b/templates/start-config/flake.nix new file mode 100644 index 0000000..13ff47d --- /dev/null +++ b/templates/start-config/flake.nix @@ -0,0 +1,35 @@ + { + description = "Home Manager configuration"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "1M0b4nc0"; + in { + homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + + modules = [ + { + home = { + inherit username; + homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; + + # TODO: how to: Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; + } diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix new file mode 100644 index 0000000..b975be5 --- /dev/null +++ b/templates/start-config/home.nix @@ -0,0 +1,1427 @@ +{ pkgs, ... }: + +{ + + # Home Manager needs a bit of information about you and the + # paths it should manage. + # home.username = "ubuntu"; + # home.homeDirectory = "/home/ubuntu"; + + home.packages = with pkgs; [ + # Graphical packages + #anydesk + #blender + #brave + #dbeaver + #discord + #gimp + #gitkraken + #google-chrome + #inkscape + #insomnia + #jetbrains.pycharm-community + #keepassxc + #kolourpaint + #libreoffice + #obsidian + #okular + #peek + #postman + #qbittorrent + #spotify + #tdesktop + #virt-manager + #vlc + #vscodium + + xorg.xclock + + # sudo $(which lshw) -C display + # sudo dmesg | grep drm + # glxgears -info + # lspci | grep -i vga + # mesa + # mesa-demos + # libglvnd # find / -name 'libGL.so' 2>/dev/null + # vulkan-loader + # vulkan-headers + # mesa_drivers + # linuxPackages.nvidia_x11 + # cudatoolkit + # cudatoolkit.lib + # mpi + + # + steam-run + + xorg.xclock + hello + sl + asciiquarium + figlet + cowsay + ponysay + cmatrix + + # Just enabling it is ok, and might be better + # nix + # nixVersions.nix_2_10 + + # pciutils # lspci and others + # coreboot-utils + + # # TODO: testar com o zsh + ## bashInteractive # https://www.reddit.com/r/NixOS/comments/zx4kmh/alpinewsl_home_manager_bash_issue/ + coreutils + binutils + utillinux + xorg.xkill + glibc.bin + patchelf + gparted + # glxinfo + file + findutils + gnugrep + gnumake + gnused + gawk + hexdump + which + xz + exfat + procps + curl + wget + lsof + tree + killall + nmap + netcat + tmate + strace + # ptrace + traceroute + man + man-db + (aspellWithDicts (d: with d; [ de en pt_BR ])) # nix repl --expr 'import {}' <<<'builtins.attrNames aspellDicts' | tr ' ' '\n' + gnome.simple-scan + imagemagick + nix-prefetch-git + nixfmt + hydra-check + nixos-option + shellcheck + + fontconfig + # fontforge-gtk # TODO: testar fontes usando esse programa + # pango + + # arphic-ukai + # arphic-uming + # aurulent-sans + # comic-relief + # corefonts # Microsoft free fonts + # dejavu_fonts + # dina-font + # fira # Monospace + # fira-code + # fira-code-symbols + # font-awesome # font-awesome-ttf, font-awesome_4 + # freefont_ttf + # hack-font + # hasklig + # inconsolata # Monospace + # ionicons + # lato + # liberation_ttf + # lineicons + # montserrat + # mplus-outline-fonts + nerdfonts # Really big, but only this font fixed some issues with starship + # noto-fonts + # noto-fonts-emoji + # noto-fonts-extra + powerline + powerline-fonts + # source-han-sans-japanese + # source-han-sans-korean + # source-han-sans-simplified-chinese + # source-han-sans-traditional-chinese + # source-sans + # source-sans-pro + # sudo-font + # symbola + # twemoji-color-font + # ubuntu_font_family + # unifont # International languages + # wqy_microhei + # wqy_zenhei + # xkcd-font + + # (nerdfonts.override { fonts = [ "FiraCode"]; }) + # ( + # nerdfonts.override { + # fonts = [ + # "AnonymousPro" + # "DroidSansMono" + # "FiraCode" + # "JetBrainsMono" + # "Noto" + # "Terminus" + # "Hack" + # "Ubuntu" + # "UbuntuMono" + # ]; + # } + # ) + + # zsh-nix-shell + # zsh-powerlevel10k + # zsh-powerlevel9k + # zsh-syntax-highlighting + + oh-my-zsh + # zsh-completions-latest + + # gcc + # gdb + # clang + # rustc + # python3Full + # julia-bin + + graphviz # dot command comes from here + jq + unixtools.xxd + + gzip + # unrar + unzip + gnutar + + btop + htop + asciinema + git + openssh + # sshfs # TODO: testar + + # #podman + # runc + # skopeo + # conmon + # slirp4netns + # shadow + + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "$HOME"/.ssh/id_ed25519 \ + -N "" \ + && echo \ + && cat "$HOME"/.ssh/id_ed25519.pub \ + && echo + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) + + ( + writeScriptBin "gphms" '' + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + nix repl --expr 'import {}' + '' + ) + ]; + + # https://github.com/nix-community/home-manager/blob/782cb855b2f23c485011a196c593e2d7e4fce746/modules/targets/generic-linux.nix + targets.genericLinux.enable = true; + + nix = { + enable = true; + # What about github:NixOS/nix#nix-static can it be injected here? What would break? + # package = pkgs.pkgsStatic.nixVersions.nix_2_10; + package = pkgs.nixVersions.nix_2_10; + # Could be useful: + # export NIX_CONFIG='extra-experimental-features = nix-command flakes' + extraOptions = '' + experimental-features = nix-command flakes + ''; + + settings = { + # use-sandbox = true; + show-trace = true; + # system-features = [ "big-parallel" "kvm" "recursive-nix" "nixos-test" ]; + keep-outputs = true; + keep-derivations = true; + + tarball-ttl = 60 * 60 * 24 * 7 * 4; # = 2419200 = one month + # readOnlyStore = true; + + # trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + # trusted-substituters = "fooooo"; + }; + }; + + nixpkgs.config = { + allowBroken = false; + allowUnfree = true; + # TODO: test it + # android_sdk.accept_license = true; + }; + + services.systembus-notify.enable = true; + services.spotifyd.enable = true; + + fonts = { + # enableFontDir = true; + # enableGhostscriptFonts = true; + # fonts = with pkgs; [ + # powerline-fonts + # ]; + fontconfig = { + enable = true; + # defaultFonts = { + # monospace = [ "Droid Sans Mono Slashed for Powerline" ]; + # }; + }; + }; + + programs.bash = { + enable = false; + # bashrcExtra = "echo foo-bar"; + sessionVariables = { + A_B_C = "a-b-c"; + FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; + }; + }; + + # TODO: documentar e testar + home.extraOutputsToInstall = [ + "/share/zsh" + "/share/bash" + "/share/fish" + "/share/fonts" # fc-cache -frv + # /etc/fonts + ]; + + # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ + programs.zsh = { + # Your zsh config + enable = true; + enableCompletion = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + envExtra = '' + if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then + . ~/.nix-profile/etc/profile.d/nix.sh + fi + ''; + + # initExtra = "neofetch --ascii_distro NixOS_small --color_blocks off --disable cpu gpu memory term de resolution kernel model"; + initExtra = "${pkgs.neofetch}/bin/neofetch"; # TODO: checar se esse pacote é seguro + + # promptInit = '' + # export POWERLEVEL9K_MODE=nerdfont-complete + # source ${pkgs.zsh-powerlevel9k}/share/zsh-powerlevel9k/powerlevel9k.zsh-theme + # ''; + + # initExtraBeforeCompInit = ''eval "$(direnv hook zsh)"''; + autocd = true; + + + shellAliases = { + l = "ls -al"; + + # + nb = "nix build"; + npi = "nix profile install nixpkgs#"; + ns = "nix shell"; + # nr = "nix repl --expr 'import {}'"; + }; + + # > closed and reopened the terminal. Then it worked. + # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 + sessionVariables = { + # EDITOR = "nvim"; + # DEFAULT_USER = "foo-bar"; + # ZSH_AUTOSUGGEST_USE_ASYNC="true"; + # ZSH_AUTOSUGGEST_MANUAL_REBIND="true"; + # PROMPT="|%F{153}%n@%m%f|%F{174}%1~%f> "; + + LANG = "en_US.utf8"; + # fc-match list + FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; + }; + + historySubstringSearch.enable = true; + + history = { + save = 50000; + size = 50000; + path = "$HOME/.cache/zsh_history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix + plugins = [ + # "autojump" + "aws" + # "cargo" + "catimg" + "colored-man-pages" + "colorize" + "command-not-found" + "common-aliases" + "copyfile" + "copypath" + "cp" + "direnv" + "docker" + "docker-compose" + "emacs" + "encode64" + "extract" + "fancy-ctrl-z" + "fzf" + "gcloud" + "git" + "git-extras" + "git-flow-avh" + "github" + "gitignore" + "gradle" + "history" + "history-substring-search" + "kubectl" + "man" + "mvn" + "node" + "npm" + "pass" + "pip" + "poetry" + "python" + "ripgrep" + "rsync" + "rust" + "scala" + "ssh-agent" + "sudo" + "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin + "systemd" + "terraform" + # "thefuck" + "tig" + "timer" + # "tmux" # It needs tmux to be installed + "vagrant" + "vi-mode" + "vim-interaction" + "yarn" + "z" + "zsh-navigation-tools" + ]; + theme = "robbyrussell"; + # theme = "bira"; + # theme = "powerlevel10k"; + # theme = "powerlevel9k/powerlevel9k"; + # theme = "agnoster"; + # theme = "gallois"; + # theme = "gentoo"; + # theme = "af-magic"; + # theme = "half-life"; + # theme = "rgm"; + # theme = "crcandy"; + # theme = "fishy"; + }; + }; + + # programs.starship = { + # enable = true; + # enableZshIntegration = true; + # }; + + # Credits: + # https://gist.github.com/s-a-c/0e44dc7766922308924812d4c019b109 + # https://gist.github.com/search?q=So+either+put+%22Important+Documents%22+before+%22Documents%22+or+use+the+substituted+version%3A%3B&ref=searchresults + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + # "$schema" = "https://starship.rs/config-schema.json"; + add_newline = true; + command_timeout = 500; + continuation_prompt = "[∙](bright-black) "; + # format = "[](0x9A348E)$username$hostname$localip$shlvl$singularity$kubernetes[](fg:0x9A348E bg:0xDA627D)$directory$vcsh[](fg:0xDA627D bg:0xFCA17D)$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch[](fg:0x86BBD8 bg:0x06969A)$docker_context$package$buf[](fg:0xFCA17D bg:0x86BBD8)$c$cmake$cobol$container$daml$dart$deno$dotnet$elixir$elm$erlang$golang$haskell$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$nix_shell$conda$spack$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery[](fg:0x06969A bg:0x33658A)$time$status$shell$character"; + right_format = ""; + scan_timeout = 30; + aws = { + format = "[$symbol($profile )(($region) )([$duration] )]($style)"; + symbol = "🅰 "; + style = "bold yellow"; + disabled = false; + expiration_symbol = "X"; + force_display = false; + }; + aws.region_aliases = {}; + aws.profile_aliases = {}; + azure = { + format = "[$symbol($subscription)([$duration])]($style) "; + symbol = "ﴃ "; + style = "blue bold"; + disabled = true; + }; + battery = { + format = "[$symbol$percentage]($style) "; + charging_symbol = " "; + discharging_symbol = " "; + empty_symbol = " "; + full_symbol = " "; + unknown_symbol = " "; + disabled = false; + display = [ + { + style = "red bold"; + threshold = 10; + } + ]; + }; + buf = { + format = "[$symbol ($version)]($style)"; + version_format = "v$raw"; + symbol = ""; + style = "bold blue"; + disabled = false; + detect_extensions = []; + detect_files = [ + "buf.yaml" + "buf.gen.yaml" + "buf.work.yaml" + ]; + detect_folders = []; + }; + c = { + format = "[$symbol($version(-$name) )]($style)"; + version_format = "v$raw"; + style = "fg:149 bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ + "c" + "h" + ]; + detect_files = []; + detect_folders = []; +# commands = [ +# [ +# "cc" +# "--version" +# ] +# [ +# "gcc" +# "--version" +# ] +# [ +# "clang" +# "--version" +# ] +# ]; + }; + character = { + format = "$symbol "; + vicmd_symbol = "[❮](bold green)"; + disabled = false; + success_symbol = "[➜](bold green) "; + error_symbol = "[✗](bold red) "; + }; + cmake = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "△ "; + style = "bold blue"; + disabled = false; + detect_extensions = []; + detect_files = [ + "CMakeLists.txt" + "CMakeCache.txt" + ]; + detect_folders = []; + }; + cmd_duration = { + min_time = 2000; + format = "⏱ [$duration]($style) "; + style = "yellow bold"; + show_milliseconds = false; + disabled = false; + show_notifications = false; + min_time_to_notify = 45000; + }; + cobol = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⚙️ "; + style = "bold blue"; + disabled = false; + detect_extensions = [ + "cbl" + "cob" + "CBL" + "COB" + ]; + detect_files = []; + detect_folders = []; + }; + conda = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = " "; + style = "green bold"; + ignore_base = true; + disabled = false; + }; + container = { + format = "[$symbol [$name]]($style) "; + symbol = "⬢"; + style = "red bold dimmed"; + disabled = false; + }; + crystal = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔮 "; + style = "bold red"; + disabled = false; + detect_extensions = ["cr"]; + detect_files = ["shard.yml"]; + detect_folders = []; + }; + dart = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🎯 "; + style = "bold blue"; + disabled = false; + detect_extensions = ["dart"]; + detect_files = [ + "pubspec.yaml" + "pubspec.yml" + "pubspec.lock" + ]; + detect_folders = [".dart_tool"]; + }; + deno = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦕 "; + style = "green bold"; + disabled = false; + detect_extensions = []; + detect_files = [ + "deno.json" + "deno.jsonc" + "mod.ts" + "deps.ts" + "mod.js" + "deps.js" + ]; + detect_folders = []; + }; + directory = { + disabled = false; + fish_style_pwd_dir_length = 0; + format = "[$path]($style)[$read_only]($read_only_style) "; + home_symbol = "~"; + read_only = " "; + read_only_style = "red"; + repo_root_format = "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; + style = "cyan bold bg:0xDA627D"; + truncate_to_repo = true; + truncation_length = 3; + truncation_symbol = "…/"; + use_logical_path = true; + use_os_path_sep = true; + }; + directory.substitutions = { + # Here is how you can shorten some long paths by text replacement; + # similar to mapped_locations in Oh My Posh:; + "Documents" = " "; + "Downloads" = " "; + "Music" = " "; + "Pictures" = " "; + # Keep in mind that the order matters. For example:; + # "Important Documents" = "  "; + # will not be replaced, because "Documents" was already substituted before.; + # So either put "Important Documents" before "Documents" or use the substituted version:; + # "Important  " = "  "; + "Important " = " "; + }; + docker_context = { + format = "[$symbol$context]($style) "; + style = "blue bold bg:0x06969A"; + symbol = " "; + only_with_files = true; + disabled = false; + detect_extensions = []; + detect_files = [ + "docker-compose.yml" + "docker-compose.yaml" + "Dockerfile" + ]; + detect_folders = []; + }; + dotnet = { + format = "[$symbol($version )(🎯 $tfm )]($style)"; + version_format = "v$raw"; + symbol = "🥅 "; + style = "blue bold"; + heuristic = true; + disabled = false; + detect_extensions = [ + "csproj" + "fsproj" + "xproj" + ]; + detect_files = [ + "global.json" + "project.json" + "Directory.Build.props" + "Directory.Build.targets" + "Packages.props" + ]; + detect_folders = []; + }; + elixir = { + format = "[$symbol($version (OTP $otp_version) )]($style)"; + version_format = "v$raw"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = []; + detect_files = ["mix.exs"]; + detect_folders = []; + }; + elm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "cyan bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = ["elm"]; + detect_files = [ + "elm.json" + "elm-package.json" + ".elm-version" + ]; + detect_folders = ["elm-stuff"]; + }; + env_var = {}; + env_var.SHELL = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + variable = "SHELL"; + default = "unknown shell"; + }; + env_var.USER = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + default = "unknown user"; + }; + erlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold red"; + disabled = false; + detect_extensions = []; + detect_files = [ + "rebar.config" + "erlang.mk" + ]; + detect_folders = []; + }; + fill = { + style = "bold black"; + symbol = "."; + disabled = false; + }; + gcloud = { + format = "[$symbol$account(@$domain)(($region))(($project))]($style) "; + symbol = "☁️ "; + style = "bold blue"; + disabled = false; + }; + gcloud.project_aliases = {}; + gcloud.region_aliases = {}; + git_branch = { + format = "[$symbol$branch(:$remote_branch)]($style) "; + symbol = " "; + style = "bold purple bg:0xFCA17D"; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + only_attached = false; + always_show_remote = false; + ignore_branches = []; + disabled = false; + }; + git_commit = { + commit_hash_length = 7; + format = "[($hash$tag)]($style) "; + style = "green bold"; + only_detached = true; + disabled = false; + tag_symbol = " 🏷 "; + tag_disabled = true; + }; + git_metrics = { + added_style = "bold green"; + deleted_style = "bold red"; + only_nonzero_diffs = true; + format = "([+$added]($added_style) )([-$deleted]($deleted_style) )"; + disabled = false; + }; + git_state = { + am = "AM"; + am_or_rebase = "AM/REBASE"; + bisect = "BISECTING"; + cherry_pick = "🍒PICKING(bold red)"; + disabled = false; + format = "([$state( $progress_current/$progress_total)]($style)) "; + merge = "MERGING"; + rebase = "REBASING"; + revert = "REVERTING"; + style = "bold yellow"; + }; + git_status = { + ahead = "🏎💨$count"; + behind = "😰$count"; + conflicted = "🏳"; + deleted = "🗑"; + disabled = false; + diverged = "😵"; + # format = "([[$all_status$ahead_behind]]($style) )"; + ignore_submodules = false; + modified = "📝"; + renamed = "👅"; + staged = "[++($count)](green)"; + stashed = "📦"; + style = "red bold bg:0xFCA17D"; + untracked = "🤷"; + up_to_date = "✓"; + }; + golang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold cyan bg:0x86BBD8"; + disabled = false; + detect_extensions = ["go"]; + detect_files = [ + "go.mod" + "go.sum" + "glide.yaml" + "Gopkg.yml" + "Gopkg.lock" + ".go-version" + ]; + detect_folders = ["Godeps"]; + }; + haskell = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "λ "; + style = "bold purple bg:0x86BBD8"; + disabled = false; + detect_extensions = [ + "hs" + "cabal" + "hs-boot" + ]; + detect_files = [ + "stack.yaml" + "cabal.project" + ]; + detect_folders = []; + }; + helm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⎈ "; + style = "bold white"; + disabled = false; + detect_extensions = []; + detect_files = [ + "helmfile.yaml" + "Chart.yaml" + ]; + detect_folders = []; + }; + hg_branch = { + symbol = " "; + style = "bold purple"; + format = "on [$symbol$branch]($style) "; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + disabled = true; + }; + hostname = { + disabled = false; + format = "[$ssh_symbol](blue dimmed bold)[$hostname]($style) "; + ssh_only = false; + style = "green dimmed bold"; + trim_at = "."; + }; + java = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "red dimmed bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = [ + "java" + "class" + "jar" + "gradle" + "clj" + "cljc" + ]; + detect_files = [ + "pom.xml" + "build.gradle.kts" + "build.sbt" + ".java-version" + "deps.edn" + "project.clj" + "build.boot" + ]; + detect_folders = []; + }; + jobs = { + threshold = 1; + symbol_threshold = 0; + number_threshold = 2; + format = "[$symbol$number]($style) "; + symbol = "✦"; + style = "bold blue"; + disabled = false; + }; + julia = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = ["jl"]; + detect_files = [ + "Project.toml" + "Manifest.toml" + ]; + detect_folders = []; + }; + kotlin = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🅺 "; + style = "bold blue"; + kotlin_binary = "kotlin"; + disabled = false; + detect_extensions = [ + "kt" + "kts" + ]; + detect_files = []; + detect_folders = []; + }; + kubernetes = { + disabled = false; + format = "[$symbol$context( ($namespace))]($style) in "; + style = "cyan bold"; + symbol = "⛵ "; + }; + kubernetes.context_aliases = {}; + line_break = { + disabled = false; + }; + localip = { + disabled = false; + format = "[@$localipv4]($style) "; + ssh_only = false; + style = "yellow bold"; + }; + lua = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🌙 "; + style = "bold blue"; + lua_binary = "lua"; + disabled = false; + detect_extensions = ["lua"]; + detect_files = [".lua-version"]; + detect_folders = ["lua"]; + }; + memory_usage = { + disabled = false; + format = "$symbol[$ram( | $swap)]($style) "; + style = "white bold dimmed"; + symbol = " "; + # threshold = 75; + threshold = -1; + }; + nim = { + format = "[$symbol($version )]($style)"; + style = "yellow bold bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "nim" + "nims" + "nimble" + ]; + detect_files = ["nim.cfg"]; + detect_folders = []; + }; + nix_shell = { + format = "[$symbol$state( ($name))]($style) "; + disabled = false; + impure_msg = "[impure](bold red)"; + pure_msg = "[pure](bold green)"; + style = "bold blue"; + symbol = " "; + }; + nodejs = { + format = "[$symbol($version )]($style)"; + not_capable_style = "bold red"; + style = "bold green bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "js" + "mjs" + "cjs" + "ts" + "mts" + "cts" + ]; + detect_files = [ + "package.json" + ".node-version" + ".nvmrc" + ]; + detect_folders = ["node_modules"]; + }; + ocaml = { + format = "[$symbol($version )(($switch_indicator$switch_name) )]($style)"; + global_switch_indicator = ""; + local_switch_indicator = "*"; + style = "bold yellow"; + symbol = "🐫 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "opam" + "ml" + "mli" + "re" + "rei" + ]; + detect_files = [ + "dune" + "dune-project" + "jbuild" + "jbuild-ignore" + ".merlin" + ]; + detect_folders = [ + "_opam" + "esy.lock" + ]; + }; + openstack = { + format = "[$symbol$cloud(($project))]($style) "; + symbol = "☁️ "; + style = "bold yellow"; + disabled = false; + }; + package = { + format = "[$symbol$version]($style) "; + symbol = "📦 "; + style = "208 bold"; + display_private = false; + disabled = false; + version_format = "v$raw"; + }; + perl = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐪 "; + style = "149 bold"; + disabled = false; + detect_extensions = [ + "pl" + "pm" + "pod" + ]; + detect_files = [ + "Makefile.PL" + "Build.PL" + "cpanfile" + "cpanfile.snapshot" + "META.json" + "META.yml" + ".perl-version" + ]; + detect_folders = []; + }; + php = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐘 "; + style = "147 bold"; + disabled = false; + detect_extensions = ["php"]; + detect_files = [ + "composer.json" + ".php-version" + ]; + detect_folders = []; + }; + pulumi = { + format = "[$symbol($username@)$stack]($style) "; + version_format = "v$raw"; + symbol = " "; + style = "bold 5"; + disabled = false; + }; + purescript = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "<=> "; + style = "bold white"; + disabled = false; + detect_extensions = ["purs"]; + detect_files = ["spago.dhall"]; + detect_folders = []; + }; + python = { + format = "[$symbol$pyenv_prefix($version )(($virtualenv) )]($style)"; + python_binary = [ + "python" + "python3" + "python2" + ]; + pyenv_prefix = "pyenv "; + pyenv_version_name = true; + style = "yellow bold"; + symbol = "🐍 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = ["py"]; + detect_files = [ + "requirements.txt" + ".python-version" + "pyproject.toml" + "Pipfile" + "tox.ini" + "setup.py" + "__init__.py" + ]; + detect_folders = []; + }; + red = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔺 "; + style = "red bold"; + disabled = false; + detect_extensions = [ + "red" + "reds" + ]; + detect_files = []; + detect_folders = []; + }; + rlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "blue bold"; + symbol = "📐 "; + disabled = false; + detect_extensions = [ + "R" + "Rd" + "Rmd" + "Rproj" + "Rsx" + ]; + detect_files = [".Rprofile"]; + detect_folders = [".Rproj.user"]; + }; + ruby = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "💎 "; + style = "bold red"; + disabled = false; + detect_extensions = ["rb"]; + detect_files = [ + "Gemfile" + ".ruby-version" + ]; + detect_folders = []; + detect_variables = [ + "RUBY_VERSION" + "RBENV_VERSION" + ]; + }; + rust = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦀 "; + style = "bold red bg:0x86BBD8"; + disabled = false; + detect_extensions = ["rs"]; + detect_files = ["Cargo.toml"]; + detect_folders = []; + }; + scala = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + disabled = false; + style = "red bold"; + symbol = "🆂 "; + detect_extensions = [ + "sbt" + "scala" + ]; + detect_files = [ + ".scalaenv" + ".sbtenv" + "build.sbt" + ]; + detect_folders = [".metals"]; + }; + shell = { + format = "[$indicator]($style) "; + bash_indicator = "bsh"; + cmd_indicator = "cmd"; + elvish_indicator = "esh"; + fish_indicator = ""; + ion_indicator = "ion"; + nu_indicator = "nu"; + powershell_indicator = "_"; + style = "white bold"; + tcsh_indicator = "tsh"; + unknown_indicator = "mystery shell"; + xonsh_indicator = "xsh"; + zsh_indicator = "zsh"; + disabled = false; + }; + shlvl = { + threshold = 2; + format = "[$symbol$shlvl]($style) "; + symbol = "↕️ "; + repeat = false; + style = "bold yellow"; + disabled = true; + }; + singularity = { + format = "[$symbol[$env]]($style) "; + style = "blue bold dimmed"; + symbol = "📦 "; + disabled = false; + }; + spack = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = "🅢 "; + style = "blue bold"; + disabled = false; + }; + status = { + format = "[$symbol$status]($style) "; + map_symbol = true; + not_executable_symbol = "🚫"; + not_found_symbol = "🔍"; + pipestatus = false; + pipestatus_format = "[$pipestatus] => [$symbol$common_meaning$signal_name$maybe_int]($style)"; + pipestatus_separator = "|"; + recognize_signal_code = true; + signal_symbol = "⚡"; + style = "bold red bg:blue"; + success_symbol = "🟢 SUCCESS"; + symbol = "🔴 "; + disabled = true; + }; + sudo = { + format = "[as $symbol]($style)"; + symbol = "🧙 "; + style = "bold blue"; + allow_windows = false; + disabled = true; + }; + swift = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐦 "; + style = "bold 202"; + disabled = false; + detect_extensions = ["swift"]; + detect_files = ["Package.swift"]; + detect_folders = []; + }; + terraform = { + format = "[$symbol$workspace]($style) "; + version_format = "v$raw"; + symbol = "💠 "; + style = "bold 105"; + disabled = false; + detect_extensions = [ + "tf" + "tfplan" + "tfstate" + ]; + detect_files = []; + detect_folders = [".terraform"]; + }; + time = { + format = "[$symbol $time]($style) "; + style = "bold yellow bg:0x33658A"; + use_12hr = false; + disabled = false; + utc_time_offset = "local"; + # time_format = "%R"; # Hour:Minute Format; + time_format = "%T"; # Hour:Minute:Seconds Format; + time_range = "-"; + }; + username = { + format = "[$user]($style) "; + show_always = true; + style_root = "red bold bg:0x9A348E"; + style_user = "yellow bold bg:0x9A348E"; + disabled = false; + }; + vagrant = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⍱ "; + style = "cyan bold"; + disabled = false; + detect_extensions = []; + detect_files = ["Vagrantfile"]; + detect_folders = []; + }; + vcsh = { + symbol = ""; + style = "bold yellow"; + format = "[$symbol$repo]($style) "; + disabled = false; + }; + vlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "V "; + style = "blue bold"; + disabled = false; + detect_extensions = ["v"]; + detect_files = [ + "v.mod" + "vpkg.json" + ".vpkg-lock.json" + ]; + detect_folders = []; + }; + zig = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "↯ "; + style = "bold yellow"; + disabled = false; + detect_extensions = ["zig"]; + detect_files = []; + detect_folders = []; + }; + custom = { + }; + }; + }; + + # https://nix-community.github.io/home-manager/options.html#opt-programs.direnv.config + programs.direnv = { + enable = true; + nix-direnv = { + enable = true; + }; + enableZshIntegration = true; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + # enableBashIntegration = true; + # enableFishIntegration = true; + }; + + # This makes it so that if you type the name of a program that + # isn't installed, it will tell you which package contains it. + # https://eevie.ro/posts/2022-01-24-how-i-nix.html + # + programs.nix-index = { + enable = true; + # enableFishIntegration = true; + # enableBashIntegration = true; + enableZshIntegration = true; + }; + + programs.home-manager = { + enable = true; + }; +} From 38274f17182494b2faa255a48aaffc75cec33c3e Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 16:35:24 -0300 Subject: [PATCH 021/191] =?UTF-8?q?Adequa=20instru=C3=A7=C3=B5es=20no=20RE?= =?UTF-8?q?ADME.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/profile/README.md b/profile/README.md index 6b6f858..4c8e5a8 100644 --- a/profile/README.md +++ b/profile/README.md @@ -15,8 +15,67 @@ NIX_RELEASE_VERSION=2.10.2 \ && . "$HOME"/.nix-profile/etc/profile.d/nix.sh export NIX_CONFIG='extra-experimental-features = nix-command flakes' +``` + + +1.1) Apenas programas CLI: + +```bash +# Precisa das variáveis de ambiente USER e HOME + +DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF + echo $DIRETORY_TO_CLONE + mkdir -pv $DIRETORY_TO_CLONE + + cd $DIRETORY_TO_CLONE + + nix \ + flake \ + init \ + --template \ + github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#templates.x86_64-linux.startConfig + + sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ + && git init \ + && git status \ + && git add . \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && git status \ + && git add . + + + export NIXPKGS_ALLOW_UNFREE=1 \ + && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs \ + && home-manager generations + + + # + TARGET_SHELL='zsh' \ + && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + && echo \ + && ls -al "\$FULL_TARGET_SHELL" \ + && echo \ + && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ + && echo \ + && sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF +``` + +1.2) Com programas com interface gráfica (precisa de no mínimo 22Gigas de espaço em disco): +```bash # Precisa das variáveis de ambiente USER e HOME DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs From 86a0e14718d8bd92b4d553c38d3a6211aa9feaa1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 10 Mar 2023 16:37:51 -0300 Subject: [PATCH 022/191] =?UTF-8?q?Adequa=20instru=C3=A7=C3=B5es=20sobre?= =?UTF-8?q?=20gerar=20chave=20ssh=20ed25519?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 4c8e5a8..2065079 100644 --- a/profile/README.md +++ b/profile/README.md @@ -132,7 +132,9 @@ EOF sudo reboot ``` -3) Adicionando uma nova chave ssh a sua conta do github: +3) Adicionando uma nova chave ssh a sua conta do github + +Use o script `generate-new-ed25519-key-pair` e acesse o link: https://github.com/settings/ssh/new From 8d85dba6d68b9e05aae356058939b462e9eae57d Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 13 Mar 2023 23:32:09 -0300 Subject: [PATCH 023/191] Adiciona myexternalip e WIP --- profile/README.md | 5 +++++ templates/start-config/home.nix | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 2065079..f36b77d 100644 --- a/profile/README.md +++ b/profile/README.md @@ -141,3 +141,8 @@ https://github.com/settings/ssh/new 4) Ir para o repositório privado do Imobanco? https://github.com/imobanco/.config-nixpkgs +5) WIP + +```bash +# rm -frv /home/"$USER"/.config/nixpkgs/.git +``` diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index b975be5..a30ff7a 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -236,9 +236,17 @@ ) ( - writeScriptBin "generate-new-ed25519-key-pair" '' + writeScriptBin "myexternalip" '' #! ${pkgs.runtimeShell} -e + # https://askubuntu.com/questions/95910/command-for-determining-my-public-ip#comment1985064_712144 + + curl https://checkip.amazonaws.com + '' + ) + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e ssh-keygen \ -t ed25519 \ -C "$(git config user.email)" \ From 37b3d7c6ecdb963bba3738995227d724f63d9606 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 00:23:25 -0300 Subject: [PATCH 024/191] WIP --- profile/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/profile/README.md b/profile/README.md index f36b77d..222c61a 100644 --- a/profile/README.md +++ b/profile/README.md @@ -146,3 +146,7 @@ https://github.com/imobanco/.config-nixpkgs ```bash # rm -frv /home/"$USER"/.config/nixpkgs/.git ``` + + +https://unix.stackexchange.com/a/395900 + From d80cdbf7c810df05d123795016c70d7c27cd168f Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 00:34:21 -0300 Subject: [PATCH 025/191] WIP, adiciona mynatip e pacote nettools --- profile/README.md | 3 --- templates/start-config/home.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 222c61a..7168054 100644 --- a/profile/README.md +++ b/profile/README.md @@ -147,6 +147,3 @@ https://github.com/imobanco/.config-nixpkgs # rm -frv /home/"$USER"/.config/nixpkgs/.git ``` - -https://unix.stackexchange.com/a/395900 - diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index a30ff7a..a94710c 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -98,6 +98,7 @@ killall nmap netcat + nettools tmate strace # ptrace @@ -243,6 +244,33 @@ curl https://checkip.amazonaws.com '' ) + ( + writeScriptBin "mynatip" '' + #! ${pkgs.runtimeShell} -e + # https://unix.stackexchange.com/a/569306 + NETWORK_INTERFACE_NAME=$(route | awk ' + BEGIN { min = -1 } + $1 == "default" { + if (min < 0 || $5 < min) { + min = $5 + iface = $8 + } + } + END { + if (iface == "") { + print "No \"default\" route found!" > "/dev/stderr" + exit 1 + } else { + print iface + exit 0 + } + } + ' + ) + + ip addr show dev $NETWORK_INTERFACE_NAME | grep "inet " | awk '{ print $2 }' | cut -d'/' -f1 + '' + ) ( writeScriptBin "generate-new-ed25519-key-pair" '' From 1491aa62d62de7e895170c076f85839d213e78bd Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 11:23:46 -0300 Subject: [PATCH 026/191] Adiciona link documentando o script mynatip --- templates/start-config/home.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index a94710c..9864593 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -248,6 +248,7 @@ writeScriptBin "mynatip" '' #! ${pkgs.runtimeShell} -e # https://unix.stackexchange.com/a/569306 + # https://serverfault.com/a/256506 NETWORK_INTERFACE_NAME=$(route | awk ' BEGIN { min = -1 } $1 == "default" { From 0960a58a0205fe5613661d1251c5361ddd61b7d9 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 11:24:33 -0300 Subject: [PATCH 027/191] fmt --- templates/start-config/home.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 9864593..36c084e 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -244,6 +244,7 @@ curl https://checkip.amazonaws.com '' ) + ( writeScriptBin "mynatip" '' #! ${pkgs.runtimeShell} -e From 589bd3f4f76199f53166af43e27e320d81e28ea5 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 11:28:07 -0300 Subject: [PATCH 028/191] fmt --- templates/start-config/home.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 36c084e..aac1bb9 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -250,6 +250,7 @@ #! ${pkgs.runtimeShell} -e # https://unix.stackexchange.com/a/569306 # https://serverfault.com/a/256506 + NETWORK_INTERFACE_NAME=$(route | awk ' BEGIN { min = -1 } $1 == "default" { From 6f4cf761ca1968cbe6d83ebf9692153e23c92953 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 15:30:11 -0300 Subject: [PATCH 029/191] Adds .envrc --- templates/start-config-graphical-full/.envrc | 1 + templates/start-config/.envrc | 1 + 2 files changed, 2 insertions(+) create mode 100644 templates/start-config-graphical-full/.envrc create mode 100644 templates/start-config/.envrc diff --git a/templates/start-config-graphical-full/.envrc b/templates/start-config-graphical-full/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/start-config-graphical-full/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/start-config/.envrc b/templates/start-config/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/start-config/.envrc @@ -0,0 +1 @@ +use flake From dd1891d741ff4426778ae206385a65d72bd92bfe Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 19:05:14 -0300 Subject: [PATCH 030/191] Refactor: adiciona .ignore com alguns defaults nos templates --- .gitignore | 6 ++++++ templates/start-config-graphical-full/.gitignore | 7 +++++++ templates/start-config/.gitignore | 1 + 3 files changed, 14 insertions(+) create mode 100644 templates/start-config-graphical-full/.gitignore create mode 100644 templates/start-config/.gitignore diff --git a/.gitignore b/.gitignore index 9f11b75..4d44c68 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ +result + .idea/ + +__pycache__/ + +*.tar.gz diff --git a/templates/start-config-graphical-full/.gitignore b/templates/start-config-graphical-full/.gitignore new file mode 100644 index 0000000..4d44c68 --- /dev/null +++ b/templates/start-config-graphical-full/.gitignore @@ -0,0 +1,7 @@ +result + +.idea/ + +__pycache__/ + +*.tar.gz diff --git a/templates/start-config/.gitignore b/templates/start-config/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/templates/start-config/.gitignore @@ -0,0 +1 @@ +.idea/ From e0b379af5a16cef076c1eb014ff03bd24175329b Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 23:14:53 -0300 Subject: [PATCH 031/191] Refactor: testa novo template, slim --- profile/README.md | 58 ++- templates/default.nix | 5 + .../start-config-graphical-full/home.nix | 2 + templates/start-config/home.nix | 9 + templates/start-slim-config/.envrc | 1 + templates/start-slim-config/.gitignore | 1 + templates/start-slim-config/flake.nix | 35 ++ templates/start-slim-config/home.nix | 447 ++++++++++++++++++ 8 files changed, 557 insertions(+), 1 deletion(-) create mode 100644 templates/start-slim-config/.envrc create mode 100644 templates/start-slim-config/.gitignore create mode 100644 templates/start-slim-config/flake.nix create mode 100644 templates/start-slim-config/home.nix diff --git a/profile/README.md b/profile/README.md index 7168054..780bb6a 100644 --- a/profile/README.md +++ b/profile/README.md @@ -18,6 +18,8 @@ export NIX_CONFIG='extra-experimental-features = nix-command flakes' ``` +Existem 3 tipos de configurações, descritos nas próximas seções. + 1.1) Apenas programas CLI: ```bash @@ -72,8 +74,62 @@ bash <<-EOF EOF ``` +1.2) Apenas programas CLI, slim: + +```bash +# Precisa das variáveis de ambiente USER e HOME + +DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF + echo $DIRETORY_TO_CLONE + mkdir -pv $DIRETORY_TO_CLONE + + cd $DIRETORY_TO_CLONE + + nix \ + flake \ + init \ + --template \ + github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#templates.x86_64-linux.startSlimConfig + + sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ + && git init \ + && git status \ + && git add . \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && git status \ + && git add . + + + export NIXPKGS_ALLOW_UNFREE=1 \ + && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs \ + && home-manager generations + + + # + TARGET_SHELL='zsh' \ + && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + && echo \ + && ls -al "\$FULL_TARGET_SHELL" \ + && echo \ + && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ + && echo \ + && sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF +``` + -1.2) Com programas com interface gráfica (precisa de no mínimo 22Gigas de espaço em disco): +1.3) Programas com interface gráfica (precisa de no mínimo 22Gigas de espaço em disco): ```bash # Precisa das variáveis de ambiente USER e HOME diff --git a/templates/default.nix b/templates/default.nix index d9e3576..ecbd2f2 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -8,4 +8,9 @@ description = "Configuração base inicial COM insterface gráfica"; path = ./start-config; }; + + startSlimConfig = { + description = "Configuração base inicial COM insterface gráfica"; + path = ./start-config; + }; } diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 9485237..af2f5b3 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -95,9 +95,11 @@ wget lsof tree + ripgrep killall nmap netcat + nettools tmate strace # ptrace diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index aac1bb9..a4549a2 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -95,6 +95,7 @@ wget lsof tree + ripgrep killall nmap netcat @@ -289,6 +290,14 @@ '' ) + ( + writeScriptBin "try-install-openss-server" '' + #! ${pkgs.runtimeShell} -e + command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) + command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) + '' + ) + ( writeScriptBin "nfm" '' #! ${pkgs.runtimeShell} -e diff --git a/templates/start-slim-config/.envrc b/templates/start-slim-config/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/templates/start-slim-config/.envrc @@ -0,0 +1 @@ +use flake diff --git a/templates/start-slim-config/.gitignore b/templates/start-slim-config/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/templates/start-slim-config/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix new file mode 100644 index 0000000..13ff47d --- /dev/null +++ b/templates/start-slim-config/flake.nix @@ -0,0 +1,35 @@ + { + description = "Home Manager configuration"; + + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "1M0b4nc0"; + in { + homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; + + modules = [ + { + home = { + inherit username; + homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; + + # TODO: how to: Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + }; + } diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix new file mode 100644 index 0000000..328e82c --- /dev/null +++ b/templates/start-slim-config/home.nix @@ -0,0 +1,447 @@ +{ pkgs, ... }: + +{ + + # Home Manager needs a bit of information about you and the + # paths it should manage. + # home.username = "ubuntu"; + # home.homeDirectory = "/home/ubuntu"; + + home.packages = with pkgs; [ + xorg.xclock + hello + + # Just enabling it is ok, and might be better + # nix + # nixVersions.nix_2_10 + + # pciutils # lspci and others + # coreboot-utils + + # # TODO: testar com o zsh + ## bashInteractive # https://www.reddit.com/r/NixOS/comments/zx4kmh/alpinewsl_home_manager_bash_issue/ + coreutils + file + findutils + gnugrep + gnumake + gnused + gawk + hexdump + which + xz + procps + curl + lsof + tree + killall +# nmap +# netcat +# nettools + tmate + strace + # ptrace +# traceroute + man + man-db +# (aspellWithDicts (d: with d; [ de en pt_BR ])) # nix repl --expr 'import {}' <<<'builtins.attrNames aspellDicts' | tr ' ' '\n' +# nix-prefetch-git +# nixfmt +# hydra-check +# nixos-option +# shellcheck + + # fontconfig + # fontforge-gtk # TODO: testar fontes usando esse programa + # pango + +# nerdfonts +# powerline +# powerline-fonts + + + # (nerdfonts.override { fonts = [ "FiraCode"]; }) + # ( + # nerdfonts.override { + # fonts = [ + # "AnonymousPro" + # "DroidSansMono" + # "FiraCode" + # "JetBrainsMono" + # "Noto" + # "Terminus" + # "Hack" + # "Ubuntu" + # "UbuntuMono" + # ]; + # } + # ) + + # zsh-nix-shell + # zsh-powerlevel10k + # zsh-powerlevel9k + # zsh-syntax-highlighting + + oh-my-zsh + # zsh-completions-latest + + # gcc + # gdb + # clang + # rustc + # python3Full + # julia-bin + +# graphviz # dot command comes from here +# jq +# unixtools.xxd + +# gzip +# # unrar +# unzip +# gnutar +# +# btop +# htop +# asciinema + git + openssh + + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "myexternalip" '' + #! ${pkgs.runtimeShell} -e + # https://askubuntu.com/questions/95910/command-for-determining-my-public-ip#comment1985064_712144 + + curl https://checkip.amazonaws.com + '' + ) + + ( + writeScriptBin "mynatip" '' + #! ${pkgs.runtimeShell} -e + # https://unix.stackexchange.com/a/569306 + # https://serverfault.com/a/256506 + + NETWORK_INTERFACE_NAME=$(route | awk ' + BEGIN { min = -1 } + $1 == "default" { + if (min < 0 || $5 < min) { + min = $5 + iface = $8 + } + } + END { + if (iface == "") { + print "No \"default\" route found!" > "/dev/stderr" + exit 1 + } else { + print iface + exit 0 + } + } + ' + ) + + ip addr show dev $NETWORK_INTERFACE_NAME | grep "inet " | awk '{ print $2 }' | cut -d'/' -f1 + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "$HOME"/.ssh/id_ed25519 \ + -N "" \ + && echo \ + && cat "$HOME"/.ssh/id_ed25519.pub \ + && echo + '' + ) + + ( + writeScriptBin "try-install-openss-server" '' + #! ${pkgs.runtimeShell} -e + command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) + command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) + + ( + writeScriptBin "gphms" '' + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + + ( + writeScriptBin "nr" '' + nix repl --expr 'import {}' + '' + ) + ]; + + # https://github.com/nix-community/home-manager/blob/782cb855b2f23c485011a196c593e2d7e4fce746/modules/targets/generic-linux.nix + targets.genericLinux.enable = true; + + nix = { + enable = true; + # What about github:NixOS/nix#nix-static can it be injected here? What would break? + # package = pkgs.pkgsStatic.nixVersions.nix_2_10; + package = pkgs.nixVersions.nix_2_10; + # Could be useful: + # export NIX_CONFIG='extra-experimental-features = nix-command flakes' + extraOptions = '' + experimental-features = nix-command flakes + ''; + + settings = { + # use-sandbox = true; + show-trace = true; + # system-features = [ "big-parallel" "kvm" "recursive-nix" "nixos-test" ]; + keep-outputs = true; + keep-derivations = true; + + tarball-ttl = 60 * 60 * 24 * 7 * 4; # = 2419200 = one month + # readOnlyStore = true; + + # trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + # trusted-substituters = "fooooo"; + }; + }; + + nixpkgs.config = { + allowBroken = false; + allowUnfree = true; + # TODO: test it + # android_sdk.accept_license = true; + }; + + services.systembus-notify.enable = true; + # services.spotifyd.enable = true; + + fonts = { + # enableFontDir = true; + # enableGhostscriptFonts = true; + # fonts = with pkgs; [ + # powerline-fonts + # ]; + fontconfig = { + enable = true; + # defaultFonts = { + # monospace = [ "Droid Sans Mono Slashed for Powerline" ]; + # }; + }; + }; + + # TODO: documentar e testar + home.extraOutputsToInstall = [ + "/share/zsh" + "/share/bash" + "/share/fish" + "/share/fonts" # fc-cache -frv + # /etc/fonts + ]; + + # https://www.reddit.com/r/NixOS/comments/fenb4u/zsh_with_ohmyzsh_with_powerlevel10k_in_nix/ + programs.zsh = { + # Your zsh config + enable = true; + enableCompletion = true; + dotDir = ".config/zsh"; + enableAutosuggestions = true; + enableSyntaxHighlighting = true; + envExtra = '' + if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then + . ~/.nix-profile/etc/profile.d/nix.sh + fi + ''; + + # initExtra = "neofetch --ascii_distro NixOS_small --color_blocks off --disable cpu gpu memory term de resolution kernel model"; + # initExtra = "${pkgs.neofetch}/bin/neofetch"; # TODO: checar se esse pacote é seguro + + # promptInit = '' + # export POWERLEVEL9K_MODE=nerdfont-complete + # source ${pkgs.zsh-powerlevel9k}/share/zsh-powerlevel9k/powerlevel9k.zsh-theme + # ''; + + # initExtraBeforeCompInit = ''eval "$(direnv hook zsh)"''; + autocd = true; + + + shellAliases = { + l = "ls -al"; + + # + nb = "nix build"; + npi = "nix profile install nixpkgs#"; + ns = "nix shell"; + # nr = "nix repl --expr 'import {}'"; + }; + + # > closed and reopened the terminal. Then it worked. + # https://discourse.nixos.org/t/home-manager-doesnt-seem-to-recognize-sessionvariables/8488/8 + sessionVariables = { + # EDITOR = "nvim"; + # DEFAULT_USER = "foo-bar"; + # ZSH_AUTOSUGGEST_USE_ASYNC="true"; + # ZSH_AUTOSUGGEST_MANUAL_REBIND="true"; + # PROMPT="|%F{153}%n@%m%f|%F{174}%1~%f> "; + + LANG = "en_US.utf8"; + # fc-match list + FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + FONTCONFIG_PATH = "${pkgs.fontconfig.out}/etc/fonts/"; + }; + + historySubstringSearch.enable = true; + + history = { + save = 50000; + size = 50000; + path = "$HOME/.cache/zsh_history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + # https://github.com/Xychic/NixOSConfig/blob/76b638086dfcde981292831106a43022588dc670/home/home-manager.nix + plugins = [ + # "autojump" + "aws" + # "cargo" + "catimg" + "colored-man-pages" + "colorize" + "command-not-found" + "common-aliases" + "copyfile" + "copypath" + "cp" + "direnv" + "docker" + "docker-compose" + "emacs" + "encode64" + "extract" + "fancy-ctrl-z" + "fzf" + "gcloud" + "git" + "git-extras" + "git-flow-avh" + "github" + "gitignore" + "gradle" + "history" + "history-substring-search" + "kubectl" + "man" + "mvn" + "node" + "npm" + "pass" + "pip" + "poetry" + "python" + "ripgrep" + "rsync" + "rust" + "scala" + "ssh-agent" + "sudo" + "systemadmin" # https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemadmin + "systemd" + "terraform" + # "thefuck" + "tig" + "timer" + # "tmux" # It needs tmux to be installed + "vagrant" + "vi-mode" + "vim-interaction" + "yarn" + "z" + "zsh-navigation-tools" + ]; + theme = "robbyrussell"; + # theme = "bira"; + # theme = "powerlevel10k"; + # theme = "powerlevel9k/powerlevel9k"; + # theme = "agnoster"; + # theme = "gallois"; + # theme = "gentoo"; + # theme = "af-magic"; + # theme = "half-life"; + # theme = "rgm"; + # theme = "crcandy"; + # theme = "fishy"; + }; + }; + + programs.starship = { + enable = true; + enableZshIntegration = true; + }; + + # https://nix-community.github.io/home-manager/options.html#opt-programs.direnv.config + programs.direnv = { + enable = true; + nix-direnv = { + enable = true; + }; + enableZshIntegration = true; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + # enableBashIntegration = true; + # enableFishIntegration = true; + }; + + # This makes it so that if you type the name of a program that + # isn't installed, it will tell you which package contains it. + # https://eevie.ro/posts/2022-01-24-how-i-nix.html + # + programs.nix-index = { + enable = true; + # enableFishIntegration = true; + # enableBashIntegration = true; + enableZshIntegration = true; + }; + + programs.home-manager = { + enable = true; + }; +} From 6d8053075cb7c2988339f935d0cce6b82b55b39f Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 23:35:58 -0300 Subject: [PATCH 032/191] Refactor: testa nerdfonts.override removendo Iosevka --- templates/start-config/home.nix | 78 ++++++++++++++++++++++------ templates/start-slim-config/home.nix | 18 ++++++- 2 files changed, 78 insertions(+), 18 deletions(-) diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index a4549a2..7682487 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -140,7 +140,7 @@ # lineicons # montserrat # mplus-outline-fonts - nerdfonts # Really big, but only this font fixed some issues with starship + # nerdfonts # Really big, but only this font fixed some issues with starship # noto-fonts # noto-fonts-emoji # noto-fonts-extra @@ -162,21 +162,65 @@ # xkcd-font # (nerdfonts.override { fonts = [ "FiraCode"]; }) - # ( - # nerdfonts.override { - # fonts = [ - # "AnonymousPro" - # "DroidSansMono" - # "FiraCode" - # "JetBrainsMono" - # "Noto" - # "Terminus" - # "Hack" - # "Ubuntu" - # "UbuntuMono" - # ]; - # } - # ) + ( + nerdfonts.override { + fonts = [ + "3270" + "Agave" + "AnonymousPro" + "Arimo" + "AurulentSansMono" + "BigBlueTerminal" + "BitstreamVeraSansMono" + "CascadiaCode" + "CodeNewRoman" + "Cousine" + "DaddyTimeMono" + "DejaVuSansMono" + "DroidSansMono" + "FantasqueSansMono" + "FiraCode" + "FiraMono" + "FontPatcher" + "Go-Mono" + "Gohu" + "Hack" + "Hasklig" + "HeavyData" + "Hermit" + "iA-Writer" + "IBMPlexMono" + "Inconsolata" + "InconsolataGo" + "InconsolataLGC" + # "Iosevka" + "JetBrainsMono" + "Lekton" + "LiberationMono" + "Lilex" + "Meslo" + "Monofur" + "Monoid" + "Mononoki" + "MPlus" + "NerdFontsSymbolsOnly" + "Noto" + "OpenDyslexic" + "Overpass" + "ProFont" + "ProggyClean" + "RobotoMono" + "ShareTechMono" + "SourceCodePro" + "SpaceMono" + "Terminus" + "Tinos" + "Ubuntu" + "UbuntuMono" + "VictorMono" + ]; + } + ) # zsh-nix-shell # zsh-powerlevel10k @@ -291,7 +335,7 @@ ) ( - writeScriptBin "try-install-openss-server" '' + writeScriptBin "try-install-openssh-server" '' #! ${pkgs.runtimeShell} -e command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 328e82c..9df7f10 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -182,13 +182,29 @@ ) ( - writeScriptBin "try-install-openss-server" '' + writeScriptBin "try-install-openssh-server" '' #! ${pkgs.runtimeShell} -e command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) '' ) + ( + writeScriptBin "try-ubuntu-screensaver-lock-disable" '' + #! ${pkgs.runtimeShell} -e + # https://linuxhint.com/disable-screen-lock-ubuntu/ + + gsettings set org.gnome.desktop.screensaver lock-enabled false + '' + ) + + ( + writeScriptBin "try-ubuntu-screensaver-lock-enable" '' + #! ${pkgs.runtimeShell} -e + gsettings set org.gnome.desktop.screensaver lock-enabled true + '' + ) + ( writeScriptBin "nfm" '' #! ${pkgs.runtimeShell} -e From beb1fd887b64f4157700f101120ed912586aa581 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 14 Mar 2023 23:57:44 -0300 Subject: [PATCH 033/191] Refactor: adiciona rm do caminho do clone --- profile/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/profile/README.md b/profile/README.md index 780bb6a..c1d1e62 100644 --- a/profile/README.md +++ b/profile/README.md @@ -33,6 +33,7 @@ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteracti --command \ bash <<-EOF echo $DIRETORY_TO_CLONE + rm -frv $DIRETORY_TO_CLONE mkdir -pv $DIRETORY_TO_CLONE cd $DIRETORY_TO_CLONE @@ -87,6 +88,7 @@ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteracti --command \ bash <<-EOF echo $DIRETORY_TO_CLONE + rm -frv $DIRETORY_TO_CLONE mkdir -pv $DIRETORY_TO_CLONE cd $DIRETORY_TO_CLONE @@ -142,6 +144,7 @@ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteracti --command \ bash <<-EOF echo $DIRETORY_TO_CLONE + rm -frv $DIRETORY_TO_CLONE mkdir -pv $DIRETORY_TO_CLONE cd $DIRETORY_TO_CLONE From c4f971bc7f193a833f0d80f450169ab19cbb93b7 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 15 Mar 2023 00:05:25 -0300 Subject: [PATCH 034/191] WIP: fixes slim --- templates/default.nix | 2 +- templates/start-config/home.nix | 106 ++++++++++++++++---------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/templates/default.nix b/templates/default.nix index ecbd2f2..0b8c73b 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -11,6 +11,6 @@ startSlimConfig = { description = "Configuração base inicial COM insterface gráfica"; - path = ./start-config; + path = ./start-slim-config; }; } diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 7682487..7fd1878 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -165,59 +165,59 @@ ( nerdfonts.override { fonts = [ - "3270" - "Agave" - "AnonymousPro" - "Arimo" - "AurulentSansMono" - "BigBlueTerminal" - "BitstreamVeraSansMono" - "CascadiaCode" - "CodeNewRoman" - "Cousine" - "DaddyTimeMono" - "DejaVuSansMono" - "DroidSansMono" - "FantasqueSansMono" - "FiraCode" - "FiraMono" - "FontPatcher" - "Go-Mono" - "Gohu" - "Hack" - "Hasklig" - "HeavyData" - "Hermit" - "iA-Writer" - "IBMPlexMono" - "Inconsolata" - "InconsolataGo" - "InconsolataLGC" - # "Iosevka" - "JetBrainsMono" - "Lekton" - "LiberationMono" - "Lilex" - "Meslo" - "Monofur" - "Monoid" - "Mononoki" - "MPlus" - "NerdFontsSymbolsOnly" - "Noto" - "OpenDyslexic" - "Overpass" - "ProFont" - "ProggyClean" - "RobotoMono" - "ShareTechMono" - "SourceCodePro" - "SpaceMono" - "Terminus" - "Tinos" - "Ubuntu" - "UbuntuMono" - "VictorMono" + # "3270" + # "Agave" + # "AnonymousPro" + # "Arimo" + # "AurulentSansMono" + # "BigBlueTerminal" + # "BitstreamVeraSansMono" + # "CascadiaCode" + # "CodeNewRoman" + # "Cousine" + # "DaddyTimeMono" + # "DejaVuSansMono" + # "DroidSansMono" + # "FantasqueSansMono" + "FiraCode" + # "FiraMono" + # "FontPatcher" + # "Go-Mono" + # "Gohu" + # "Hack" + # "Hasklig" + # "HeavyData" + # "Hermit" + # "iA-Writer" + # "IBMPlexMono" + # "Inconsolata" + # "InconsolataGo" + # "InconsolataLGC" + # "Iosevka" + "JetBrainsMono" + # "Lekton" + # "LiberationMono" + # "Lilex" + # "Meslo" + # "Monofur" + # "Monoid" + # "Mononoki" + # "MPlus" + # "NerdFontsSymbolsOnly" + # "Noto" + # "OpenDyslexic" + # "Overpass" + # "ProFont" + # "ProggyClean" + # "RobotoMono" + # "ShareTechMono" + # "SourceCodePro" + # "SpaceMono" + # "Terminus" + # "Tinos" + "Ubuntu" + # "UbuntuMono" + # "VictorMono" ]; } ) From 89cda86bda9b0a0f85354aafbfa2c3b991f77edc Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 30 Mar 2023 00:38:37 -0300 Subject: [PATCH 035/191] Testa substituter e trusted-public-keys --- templates/start-config/home.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 7fd1878..dfe21eb 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -349,6 +349,13 @@ '' ) + ( + writeScriptBin "hms" '' + export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs" + '' + ) + ( writeScriptBin "gphms" '' echo $(cd "$HOME/.config/nixpkgs" && git pull) \ @@ -376,6 +383,8 @@ # export NIX_CONFIG='extra-experimental-features = nix-command flakes' extraOptions = '' experimental-features = nix-command flakes + trusted-public-keys = binarycache-1:tcdI+LZIBrh5xmvW2P0NO5ZPwTKpkCoGq3Hmmj58yOI= + substituters = https://playing-bucket-nix-cache-test.s3.amazonaws.com ''; settings = { From e787e0cf0030b75252ebffaf422925a3d245d3cd Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 30 Mar 2023 14:58:40 -0300 Subject: [PATCH 036/191] Corrige typo --- profile/README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/profile/README.md b/profile/README.md index c1d1e62..e20466d 100644 --- a/profile/README.md +++ b/profile/README.md @@ -25,18 +25,18 @@ Existem 3 tipos de configurações, descritos nas próximas seções. ```bash # Precisa das variáveis de ambiente USER e HOME -DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs +DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs nix \ shell \ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ --command \ bash <<-EOF - echo $DIRETORY_TO_CLONE - rm -frv $DIRETORY_TO_CLONE - mkdir -pv $DIRETORY_TO_CLONE + echo $DIRECTORY_TO_CLONE + rm -frv $DIRECTORY_TO_CLONE + mkdir -pv $DIRECTORY_TO_CLONE - cd $DIRETORY_TO_CLONE + cd $DIRECTORY_TO_CLONE nix \ flake \ @@ -80,18 +80,18 @@ EOF ```bash # Precisa das variáveis de ambiente USER e HOME -DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs +DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs nix \ shell \ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ --command \ bash <<-EOF - echo $DIRETORY_TO_CLONE - rm -frv $DIRETORY_TO_CLONE - mkdir -pv $DIRETORY_TO_CLONE + echo $DIRECTORY_TO_CLONE + rm -frv $DIRECTORY_TO_CLONE + mkdir -pv $DIRECTORY_TO_CLONE - cd $DIRETORY_TO_CLONE + cd $DIRECTORY_TO_CLONE nix \ flake \ @@ -136,18 +136,18 @@ EOF ```bash # Precisa das variáveis de ambiente USER e HOME -DIRETORY_TO_CLONE=/home/"$USER"/.config/nixpkgs +DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs nix \ shell \ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ --command \ bash <<-EOF - echo $DIRETORY_TO_CLONE - rm -frv $DIRETORY_TO_CLONE - mkdir -pv $DIRETORY_TO_CLONE + echo $DIRECTORY_TO_CLONE + rm -frv $DIRECTORY_TO_CLONE + mkdir -pv $DIRECTORY_TO_CLONE - cd $DIRETORY_TO_CLONE + cd $DIRECTORY_TO_CLONE nix \ flake \ From 758600206d096b949bcaedb94cdee1794f2224bd Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 31 Mar 2023 12:36:56 -0300 Subject: [PATCH 037/191] WIP, teste do cache no s3 --- profile/README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/profile/README.md b/profile/README.md index e20466d..7fb8134 100644 --- a/profile/README.md +++ b/profile/README.md @@ -52,6 +52,18 @@ bash <<-EOF && git status \ && git add . + # TODO: ainda não foi testado + nix \ + --option eval-cache false \ + --option extra-trusted-public-keys binarycache-1:vBBc6CVmjXj5dPH0x5zPPZvkc1U9QbVoSqHcUcx6cSY= \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + build \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations.vagrant.activationPackage export NIXPKGS_ALLOW_UNFREE=1 \ && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs \ @@ -206,3 +218,43 @@ https://github.com/imobanco/.config-nixpkgs # rm -frv /home/"$USER"/.config/nixpkgs/.git ``` + + +### Mac + + +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" \ +&& echo 'eval "$(/opt/homebrew/bin/brew shellenv)' >> "$HOME"/.zprofile +``` + + + +```bash +brew install hello +``` + + +```bash +brew uninstall hello +``` + +```bash +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s + +export NIX_CONFIG='extra-experimental-features = nix-command flakes' +``` + + +```bash +nix build -L --no-link --rebuild nixpkgs#hello +``` + +```bash +nix build -L nixpkgs#pkgsCross.x86_64-embedded.hello +``` + +```bash +nix build -L nixpkgs#pkgsCross.x86_64-embedded.pkgsStatic.hello +``` From 4c5423cbf9eceaecc89c885a186ff1a07c434355 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 1 Apr 2023 05:14:56 -0300 Subject: [PATCH 038/191] Testa homeConfigurations."${username}-${hostname}" --- profile/README.md | 70 ++++++++++++++++++++++++++++++++ templates/start-config/flake.nix | 3 +- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 7fb8134..9d2a96d 100644 --- a/profile/README.md +++ b/profile/README.md @@ -87,6 +87,76 @@ bash <<-EOF EOF ``` + + +```bash +# Precisa das variáveis de ambiente USER e HOME + +DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs + +nix \ +shell \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF + echo $DIRECTORY_TO_CLONE + rm -frv $DIRECTORY_TO_CLONE + mkdir -pv $DIRECTORY_TO_CLONE + + cd $DIRECTORY_TO_CLONE + + nix \ + flake \ + init \ + --template \ + github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#templates.x86_64-linux.startConfig + + sed -i 's/username = ".*";/username = "'"$(id -un)"'";/g' flake.nix \ + && sed -i 's/hostname = ".*";/hostname = "'"$(hostname)"'";/g' flake.nix \ + && git init \ + && git status \ + && git add . \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && git status \ + && git add . + + export NIXPKGS_ALLOW_UNFREE=1 + + nix \ + build \ + --impure \ + --eval-store auto \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + --store ssh-ng://builder \ + --substituters '' \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + + && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs#"$(id -un)"-"$(hostname)" \ + && home-manager generations + + + # + TARGET_SHELL='zsh' \ + && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + && echo \ + && ls -al "\$FULL_TARGET_SHELL" \ + && echo \ + && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ + && echo \ + && sudo \ + -k \ + usermod \ + -s \ + /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$USER" +EOF +``` + + 1.2) Apenas programas CLI, slim: ```bash diff --git a/templates/start-config/flake.nix b/templates/start-config/flake.nix index 13ff47d..0464f91 100644 --- a/templates/start-config/flake.nix +++ b/templates/start-config/flake.nix @@ -12,8 +12,9 @@ let system = "x86_64-linux"; username = "1M0b4nc0"; + hostname = "fooo"; in { - homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration { + homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; modules = [ From c1fd517db556a461964d6a9485ec1561425bd663 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 1 Apr 2023 05:18:45 -0300 Subject: [PATCH 039/191] Testa homeConfigurations."${username}-${hostname}" --- profile/README.md | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/profile/README.md b/profile/README.md index 9d2a96d..7fea04f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -92,7 +92,7 @@ EOF ```bash # Precisa das variáveis de ambiente USER e HOME -DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs +DIRECTORY_TO_CLONE="$(pwd)" nix \ shell \ @@ -132,27 +132,8 @@ bash <<-EOF --print-build-logs \ --print-out-paths \ --store ssh-ng://builder \ - --substituters '' \ - ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage - - && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs#"$(id -un)"-"$(hostname)" \ - && home-manager generations - - - # - TARGET_SHELL='zsh' \ - && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - && echo \ - && ls -al "\$FULL_TARGET_SHELL" \ - && echo \ - && echo "\$FULL_TARGET_SHELL" | sudo tee -a /etc/shells \ - && echo \ - && sudo \ - -k \ - usermod \ - -s \ - /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - "$USER" + --substituters "" \ + .#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage EOF ``` From ace5069dca957ad175f9789f5dc87e57b15b96c1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 1 Apr 2023 20:03:13 -0300 Subject: [PATCH 040/191] Testa homeConfigurations."${username}-${hostname}" e slim --- profile/README.md | 89 ++++++++++++++++++++++++++- templates/start-slim-config/flake.nix | 3 +- 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 7fea04f..b304d97 100644 --- a/profile/README.md +++ b/profile/README.md @@ -17,6 +17,13 @@ NIX_RELEASE_VERSION=2.10.2 \ export NIX_CONFIG='extra-experimental-features = nix-command flakes' ``` +nix \ +store \ +gc \ +--verbose \ +--option keep-derivations false \ +--option keep-outputs false \ +&& nix-collect-garbage --delete-old Existem 3 tipos de configurações, descritos nas próximas seções. @@ -89,10 +96,24 @@ EOF +```bash +tee ~/.ssh/config < Date: Sun, 2 Apr 2023 22:15:57 -0300 Subject: [PATCH 041/191] Adiciona devShells.default --- profile/README.md | 104 ++++++++++++++++++ .../start-config-graphical-full/flake.nix | 17 +++ templates/start-config/flake.nix | 17 +++ templates/start-slim-config/flake.nix | 18 +++ 4 files changed, 156 insertions(+) diff --git a/profile/README.md b/profile/README.md index b304d97..37a4068 100644 --- a/profile/README.md +++ b/profile/README.md @@ -222,6 +222,110 @@ EOF ``` +Running it directly in the builder: +```bash +# Precisa das variáveis de ambiente USER e HOME + +DIRECTORY_TO_CLONE="$(pwd)"/test-home-manager-s3-cache + + +export DUMMY_USER=alpine +# export USER="$USER" +# export USER="$(id -un)" + +# TODO: Mac +# export HOME="$HOME" +export DUMMY_HOME=/home/"$USER" + +export DUMMY_HOSTNAME=alpine316.localdomain +# export HOSTNAME="$(hostname)" + +HM_ATTR_FULL_NAME='"'"$DUMMY_USER"-"$DUMMY_HOSTNAME"'"' +FLAKE_ATTR=".#homeConfigurations.""$HM_ATTR_FULL_NAME"".activationPackage" + + +time \ +nix \ +shell \ +--refresh \ +github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +--command \ +bash <<-EOF + echo $DIRECTORY_TO_CLONE + rm -frv $DIRECTORY_TO_CLONE + mkdir -pv $DIRECTORY_TO_CLONE + + cd $DIRECTORY_TO_CLONE + + nix \ + flake \ + init \ + --template \ + github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#templates.x86_64-linux.startSlimConfig + + sed -i 's/username = ".*";/username = "'"$DUMMY_USER"'";/g' flake.nix \ + && sed -i 's/hostname = ".*";/hostname = "'"$DUMMY_HOSTNAME"'";/g' flake.nix \ + && git init \ + && git status \ + && git add . \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && git status \ + && git add . +EOF + + +cd $DIRECTORY_TO_CLONE + +# echo "$FLAKE_ATTR" +nix eval --raw "$FLAKE_ATTR" + +export NIXPKGS_ALLOW_UNFREE=1 + +nix \ +build \ +--impure \ +--eval-store auto \ +--keep-failed \ +--no-link \ +--print-build-logs \ +--print-out-paths \ +"$FLAKE_ATTR" + +CACHE=s3://playing-bucket-nix-cache-test/ + +nix copy --no-check-sigs --eval-store auto -vvvv --to "$CACHE" \ +$(nix eval --raw "$FLAKE_ATTR") +``` + + + +```bash +rm -frv "$DIRECTORY_TO_CLONE" +``` + +```bash +nix \ +--option trusted-public-keys binarycache-1:PbJHKsLPq2DJ2OXhvqk1VgwFl04tvaHz3PzjZrrFNh0= \ +store \ +ls \ +--store 's3://playing-bucket-nix-cache-test/' \ +--long \ +--recursive \ +$(nix eval --raw "$FLAKE_ATTR") +``` + + +```bash +nix \ +--option trusted-public-keys binarycache-1:PbJHKsLPq2DJ2OXhvqk1VgwFl04tvaHz3PzjZrrFNh0= \ +store \ +ls \ +--store 's3://playing-bucket-nix-cache-test/' \ +--long \ +--recursive \ +$(nix eval --raw github:NixOS/nixpkgs/3954218cf613eba8e0dcefa9abe337d26bc48fd0#blender) +``` + 1.2) Apenas programas CLI, slim: diff --git a/templates/start-config-graphical-full/flake.nix b/templates/start-config-graphical-full/flake.nix index 13ff47d..5f9da62 100644 --- a/templates/start-config-graphical-full/flake.nix +++ b/templates/start-config-graphical-full/flake.nix @@ -31,5 +31,22 @@ # TODO: how to: Optionally use extraSpecialArgs # to pass through arguments to home.nix }; + + devShells.default = pkgsAllowUnfree.mkShell { + buildInputs = with pkgsAllowUnfree; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; + + shellHook = '' + echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat + ''; + }; }; } diff --git a/templates/start-config/flake.nix b/templates/start-config/flake.nix index 0464f91..aed9dea 100644 --- a/templates/start-config/flake.nix +++ b/templates/start-config/flake.nix @@ -32,5 +32,22 @@ # TODO: how to: Optionally use extraSpecialArgs # to pass through arguments to home.nix }; + + devShells.default = pkgsAllowUnfree.mkShell { + buildInputs = with pkgsAllowUnfree; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; + + shellHook = '' + echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat + ''; + }; }; } diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 0464f91..d0f09a0 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -32,5 +32,23 @@ # TODO: how to: Optionally use extraSpecialArgs # to pass through arguments to home.nix }; + + devShells.default = pkgsAllowUnfree.mkShell { + buildInputs = with pkgsAllowUnfree; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; + + shellHook = '' + echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat + ''; + }; + }; } From 9caed6556fd11dc9f583910b8281469f697a0d12 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 2 Apr 2023 22:22:24 -0300 Subject: [PATCH 042/191] Adiciona devShells.default, fix? --- templates/start-slim-config/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index d0f09a0..2fb9030 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -33,7 +33,7 @@ # to pass through arguments to home.nix }; - devShells.default = pkgsAllowUnfree.mkShell { + devShells.default = pkgs.mkShell { buildInputs = with pkgsAllowUnfree; [ bashInteractive coreutils From d113605d9451cc8ba65f6608f0c4c4cbf196f3a5 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 2 Apr 2023 22:25:06 -0300 Subject: [PATCH 043/191] Adiciona devShells.default, fix? --- templates/start-slim-config/flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 2fb9030..85b2bdf 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -13,6 +13,8 @@ system = "x86_64-linux"; username = "1M0b4nc0"; hostname = "fooo"; + + pkgs = nixpkgs.legacyPackages.${system}; in { homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; From 4af7bdd99caf692e079ba01e6bb4f81119194276 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 2 Apr 2023 22:27:39 -0300 Subject: [PATCH 044/191] Adiciona devShells.default, fix? --- templates/start-slim-config/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 85b2bdf..5603d1e 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -36,7 +36,7 @@ }; devShells.default = pkgs.mkShell { - buildInputs = with pkgsAllowUnfree; [ + buildInputs = with pkgs; [ bashInteractive coreutils curl From 086cb77162231401d903a39e4564747f804d379d Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 2 Apr 2023 22:29:51 -0300 Subject: [PATCH 045/191] Adiciona devShells.default, fix? --- templates/start-slim-config/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 5603d1e..432bf08 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -48,7 +48,7 @@ ]; shellHook = '' - echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat + echo -e 'IMO \n Banco' | "${pkgs.figlet}/bin/figlet" | cat ''; }; From 225b192d4436465c2be994a80e96d4c22bf48062 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 2 Apr 2023 22:37:59 -0300 Subject: [PATCH 046/191] Adiciona devShells.default, fixed --- templates/start-config-graphical-full/flake.nix | 8 ++------ templates/start-config/flake.nix | 8 ++------ templates/start-slim-config/flake.nix | 6 +----- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/templates/start-config-graphical-full/flake.nix b/templates/start-config-graphical-full/flake.nix index 5f9da62..8b2d0e6 100644 --- a/templates/start-config-graphical-full/flake.nix +++ b/templates/start-config-graphical-full/flake.nix @@ -32,8 +32,8 @@ # to pass through arguments to home.nix }; - devShells.default = pkgsAllowUnfree.mkShell { - buildInputs = with pkgsAllowUnfree; [ + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ bashInteractive coreutils curl @@ -43,10 +43,6 @@ python3Full tmate ]; - - shellHook = '' - echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat - ''; }; }; } diff --git a/templates/start-config/flake.nix b/templates/start-config/flake.nix index aed9dea..6ff79bf 100644 --- a/templates/start-config/flake.nix +++ b/templates/start-config/flake.nix @@ -33,8 +33,8 @@ # to pass through arguments to home.nix }; - devShells.default = pkgsAllowUnfree.mkShell { - buildInputs = with pkgsAllowUnfree; [ + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ bashInteractive coreutils curl @@ -44,10 +44,6 @@ python3Full tmate ]; - - shellHook = '' - echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat - ''; }; }; } diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 432bf08..6eb1100 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -35,7 +35,7 @@ # to pass through arguments to home.nix }; - devShells.default = pkgs.mkShell { + devShells.x86_64-linux.default = pkgs.mkShell { buildInputs = with pkgs; [ bashInteractive coreutils @@ -46,10 +46,6 @@ python3Full tmate ]; - - shellHook = '' - echo -e 'IMO \n Banco' | "${pkgs.figlet}/bin/figlet" | cat - ''; }; }; From 7ba24ff39ded2096b6dafd15c4b6ce95574b5077 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 3 Apr 2023 02:12:16 -0300 Subject: [PATCH 047/191] Muitos fixes, ainda WIP --- profile/README.md | 116 +++++++++++++++--- .../start-config-graphical-full/flake.nix | 5 +- 2 files changed, 100 insertions(+), 21 deletions(-) diff --git a/profile/README.md b/profile/README.md index 37a4068..9a53f4a 100644 --- a/profile/README.md +++ b/profile/README.md @@ -34,6 +34,22 @@ Existem 3 tipos de configurações, descritos nas próximas seções. DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs + +# export DUMMY_USER=alpine +export DUMMY_USER="$USER" +# export DUMMY_USER="$(id -un)" + +# TODO: Mac +# export DUMMY_HOME="$HOME" +export DUMMY_HOME=/home/"$USER" + +# export DUMMY_HOSTNAME=alpine316.localdomain +export DUMMY_HOSTNAME="$(hostname)" + +HM_ATTR_FULL_NAME='"'"$DUMMY_USER"-"$DUMMY_HOSTNAME"'"' +FLAKE_ATTR="$DIRECTORY_TO_CLONE""#homeConfigurations."'\"'"$HM_ATTR_FULL_NAME"'\"'".activationPackage" + + nix \ shell \ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ @@ -49,9 +65,10 @@ bash <<-EOF flake \ init \ --template \ - github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#templates.x86_64-linux.startConfig + github:PedroRegisPOAR/.github/feature/dx-with-nix-and-home-manager#templates.x86_64-linux.startSlimConfig - sed -i 's/username = ".*";/username = "'$USER'";/g' flake.nix \ + sed -i 's/username = ".*";/username = "'$DUMMY_USER'";/g' flake.nix \ + && sed -i 's/hostname = ".*";/hostname = "'"$DUMMY_HOSTNAME"'";/g' flake.nix \ && git init \ && git status \ && git add . \ @@ -59,10 +76,10 @@ bash <<-EOF && git status \ && git add . - # TODO: ainda não foi testado + echo "$FLAKE_ATTR" nix \ --option eval-cache false \ - --option extra-trusted-public-keys binarycache-1:vBBc6CVmjXj5dPH0x5zPPZvkc1U9QbVoSqHcUcx6cSY= \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ build \ --keep-failed \ @@ -70,16 +87,15 @@ bash <<-EOF --no-link \ --print-build-logs \ --print-out-paths \ - ~/.config/nixpkgs#homeConfigurations.vagrant.activationPackage + "$FLAKE_ATTR" export NIXPKGS_ALLOW_UNFREE=1 \ - && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs \ + && home-manager switch -b backuphm --impure --flake "$DIRECTORY_TO_CLONE"#"$HM_ATTR_FULL_NAME" \ && home-manager generations - # TARGET_SHELL='zsh' \ - && FULL_TARGET_SHELL=/home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + && FULL_TARGET_SHELL=/home/"$DUMMY_USER"/.nix-profile/bin/"\$TARGET_SHELL" \ && echo \ && ls -al "\$FULL_TARGET_SHELL" \ && echo \ @@ -89,12 +105,25 @@ bash <<-EOF -k \ usermod \ -s \ - /home/"$USER"/.nix-profile/bin/"\$TARGET_SHELL" \ - "$USER" + /home/"$DUMMY_USER"/.nix-profile/bin/"\$TARGET_SHELL" \ + "$DUMMY_USER" + EOF ``` - +```bash +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +--option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ +build \ +--keep-failed \ +--max-jobs 0 \ +--no-link \ +--print-build-logs \ +--print-out-paths \ +/nix/store/8c3ssm2avqxyfhcz7jik9s857s3kyz0q-home-manager-generation +``` ```bash tee ~/.ssh/config < Date: Mon, 3 Apr 2023 02:45:32 -0300 Subject: [PATCH 048/191] Limpa --- profile/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 9a53f4a..212d453 100644 --- a/profile/README.md +++ b/profile/README.md @@ -200,9 +200,6 @@ bash <<-EOF EOF ``` - --max-jobs 0 \ - --store ssh-ng://builder \ - --substituters "" \ ```bash From e6faaaa84e752aa3effc21901dea8dea399dc1f7 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 3 Apr 2023 21:03:43 -0300 Subject: [PATCH 049/191] Adiciona TODO --- profile/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/profile/README.md b/profile/README.md index 212d453..b4b7092 100644 --- a/profile/README.md +++ b/profile/README.md @@ -77,6 +77,7 @@ bash <<-EOF && git add . echo "$FLAKE_ATTR" + # TODO: --max-jobs 0 \ nix \ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ From d939e163a0ad5432ee36af20ef9cc4c112794128 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 3 Apr 2023 21:13:06 -0300 Subject: [PATCH 050/191] Testa fixes --- templates/start-config-graphical-full/home.nix | 9 ++++++++- templates/start-config/home.nix | 8 ++++++-- templates/start-slim-config/home.nix | 9 ++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index af2f5b3..2a5dba1 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -259,11 +259,18 @@ '' ) + ( + writeScriptBin "hms" '' + export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" + '' + ) + ( writeScriptBin "gphms" '' echo $(cd "$HOME/.config/nixpkgs" && git pull) \ && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" '' ) diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index dfe21eb..9022a99 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -352,15 +352,19 @@ ( writeScriptBin "hms" '' export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" '' ) ( writeScriptBin "gphms" '' + + DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs + + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" '' ) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 9df7f10..ca37e02 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -212,11 +212,18 @@ '' ) + ( + writeScriptBin "hms" '' + export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" + '' + ) + ( writeScriptBin "gphms" '' echo $(cd "$HOME/.config/nixpkgs" && git pull) \ && export NIXPKGS_ALLOW_UNFREE=1; \ - home-manager switch --impure --flake "$HOME/.config/nixpkgs" + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" '' ) From 9934992d251f984a22bd091373cdcdd76a5b9ef1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 3 Apr 2023 23:00:43 -0300 Subject: [PATCH 051/191] Cria comando gphms-cache --- .../start-config-graphical-full/home.nix | 32 +++++++++++++++++++ templates/start-config/home.nix | 32 +++++++++++++++++++ templates/start-slim-config/home.nix | 32 +++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 2a5dba1..80636b0 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -274,6 +274,38 @@ '' ) + ( + writeScriptBin "build-pulling-all-from-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + nix \ + --option eval-cache false \ + --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + build \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + '' + ) + + ( + writeScriptBin "gphms-cache" '' + #! ${pkgs.runtimeShell} -e + + build-pulling-all-from-cache + + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" + '' + ) + ( writeScriptBin "nr" '' nix repl --expr 'import {}' diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 9022a99..fcb7995 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -368,6 +368,38 @@ '' ) + ( + writeScriptBin "build-pulling-all-from-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + nix \ + --option eval-cache false \ + --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + build \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + '' + ) + + ( + writeScriptBin "gphms-cache" '' + #! ${pkgs.runtimeShell} -e + + build-pulling-all-from-cache + + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" + '' + ) + ( writeScriptBin "nr" '' nix repl --expr 'import {}' diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index ca37e02..daf72f2 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -227,6 +227,38 @@ '' ) + ( + writeScriptBin "build-pulling-all-from-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + nix \ + --option eval-cache false \ + --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + build \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + '' + ) + + ( + writeScriptBin "gphms-cache" '' + #! ${pkgs.runtimeShell} -e + + build-pulling-all-from-cache + + echo $(cd "$HOME/.config/nixpkgs" && git pull) \ + && export NIXPKGS_ALLOW_UNFREE=1; \ + home-manager switch --impure --flake "$HOME/.config/nixpkgs"#"$(id -un)"-"$(hostname)" + '' + ) + ( writeScriptBin "nr" '' nix repl --expr 'import {}' From be616fc3128011d499b4ff33c7ee219a7d2d5d45 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 3 Apr 2023 23:07:44 -0300 Subject: [PATCH 052/191] Adds btop --- templates/start-slim-config/home.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index daf72f2..886cf98 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -35,6 +35,7 @@ lsof tree killall + btop # nmap # netcat # nettools From 50979a48c816a5d80121413239be1598a61d2ffa Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 3 Apr 2023 23:59:36 -0300 Subject: [PATCH 053/191] Cleaning --- profile/README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/profile/README.md b/profile/README.md index b4b7092..3e56b22 100644 --- a/profile/README.md +++ b/profile/README.md @@ -17,13 +17,6 @@ NIX_RELEASE_VERSION=2.10.2 \ export NIX_CONFIG='extra-experimental-features = nix-command flakes' ``` -nix \ -store \ -gc \ ---verbose \ ---option keep-derivations false \ ---option keep-outputs false \ -&& nix-collect-garbage --delete-old Existem 3 tipos de configurações, descritos nas próximas seções. From b6303f4d3fa4922b2c19c4a09c9cbf4c599d6e5c Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 4 Apr 2023 03:19:26 -0300 Subject: [PATCH 054/191] Muitos fixes, ainda WIP --- templates/start-config-graphical-full/home.nix | 7 +++++++ templates/start-config/home.nix | 14 ++++++++++++++ templates/start-slim-config/home.nix | 7 +++++++ 3 files changed, 28 insertions(+) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 80636b0..39d3ec4 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -280,8 +280,15 @@ set -x + export NIXPKGS_ALLOW_UNFREE=1 + nix \ --option eval-cache false \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + build \ + --impure \ + --keep-failed \ --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ build \ diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index fcb7995..6f8f7b6 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -331,6 +331,13 @@ && echo \ && cat "$HOME"/.ssh/id_ed25519.pub \ && echo + + + while $(echo 'yes' | ssh -T -o ConnectTimeout=1 git@github.com &>/dev/null); do echo $(date +'%d/%m/%Y %H:%M:%S:%3N') && sleep 0.5; done + + ssh -T -o ConnectTimeout=1 git@github.com &>/dev/null + test $? -eq 1 || echo "Error in ssh -T -o ConnectTimeout=1 git@github.com + '' ) @@ -374,8 +381,15 @@ set -x + export NIXPKGS_ALLOW_UNFREE=1 + nix \ --option eval-cache false \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + build \ + --impure \ + --keep-failed \ --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ build \ diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 886cf98..8b8c00c 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -234,8 +234,15 @@ set -x + export NIXPKGS_ALLOW_UNFREE=1 + nix \ --option eval-cache false \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + build \ + --impure \ + --keep-failed \ --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ build \ From 690ab3c05875fbba1fa6cd5f89a55b8513280172 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 4 Apr 2023 03:36:14 -0300 Subject: [PATCH 055/191] Add time a comando --- profile/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/profile/README.md b/profile/README.md index 3e56b22..dd1d854 100644 --- a/profile/README.md +++ b/profile/README.md @@ -43,7 +43,11 @@ HM_ATTR_FULL_NAME='"'"$DUMMY_USER"-"$DUMMY_HOSTNAME"'"' FLAKE_ATTR="$DIRECTORY_TO_CLONE""#homeConfigurations."'\"'"$HM_ATTR_FULL_NAME"'\"'".activationPackage" +time \ nix \ +--option eval-cache false \ +--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +--option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ shell \ github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ --command \ From fcc98250973a26b3f2f6b72edc408dc49b879567 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 4 Apr 2023 03:50:27 -0300 Subject: [PATCH 056/191] Fix --- templates/start-config-graphical-full/home.nix | 2 +- templates/start-config/home.nix | 2 +- templates/start-slim-config/home.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 39d3ec4..9ebc6dc 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -286,7 +286,7 @@ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - build \ + --impure \ --keep-failed \ --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 6f8f7b6..1e8bded 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -387,7 +387,7 @@ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - build \ + --impure \ --keep-failed \ --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 8b8c00c..b1d100d 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -240,7 +240,7 @@ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - build \ + --impure \ --keep-failed \ --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ From 820f274f2428afb03e0f3a562ac42fbdd6b761f6 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 4 Apr 2023 03:59:20 -0300 Subject: [PATCH 057/191] Fix --- templates/start-config-graphical-full/home.nix | 8 ++------ templates/start-config/home.nix | 8 ++------ templates/start-slim-config/home.nix | 8 ++------ 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 9ebc6dc..0960435 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -284,14 +284,10 @@ nix \ --option eval-cache false \ - --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - - --impure \ - --keep-failed \ - --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ build \ + --impure \ --keep-failed \ --max-jobs 0 \ --no-link \ diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 1e8bded..288a7d7 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -385,14 +385,10 @@ nix \ --option eval-cache false \ - --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - - --impure \ - --keep-failed \ - --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ build \ + --impure \ --keep-failed \ --max-jobs 0 \ --no-link \ diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index b1d100d..3bdbc09 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -238,14 +238,10 @@ nix \ --option eval-cache false \ - --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - - --impure \ - --keep-failed \ - --option extra-trusted-public-keys binarycache-1:297elYH7T55M/46HB/OvrDQ8ATo4+WbQOwmgKrqoy/Q= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ build \ + --impure \ --keep-failed \ --max-jobs 0 \ --no-link \ From c80e4df8d6ccf649455d43fe397c32a938a96145 Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Thu, 6 Apr 2023 15:52:48 -0300 Subject: [PATCH 058/191] Corrige comando para instalar homebrew --- profile/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/profile/README.md b/profile/README.md index dd1d854..12a1906 100644 --- a/profile/README.md +++ b/profile/README.md @@ -535,8 +535,8 @@ https://github.com/imobanco/.config-nixpkgs ```bash -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" \ -&& echo 'eval "$(/opt/homebrew/bin/brew shellenv)' >> "$HOME"/.zprofile +NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/fc8acb0828f89f8aa83162000db1b49de71fa5d8/install.sh)" \ +&& echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME"/.zprofile ``` @@ -550,6 +550,8 @@ brew install hello brew uninstall hello ``` +#### Mac and nix + ```bash NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s From 78c3898ba64adb1e180b77db7c0a222c4f07e8c8 Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Thu, 6 Apr 2023 16:51:45 -0300 Subject: [PATCH 059/191] Fix Mac? --- profile/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 12a1906..811b33f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -554,9 +554,8 @@ brew uninstall hello ```bash NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s - -export NIX_CONFIG='extra-experimental-features = nix-command flakes' +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ +&& echo 'export NIX_CONFIG="extra-experimental-features = "nix-command flakes"' >> "$HOME"/.zprofile ``` From 5b9e7cc0e5cb06eb0f1794e46f449e89e7a06ce4 Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Thu, 6 Apr 2023 17:02:47 -0300 Subject: [PATCH 060/191] Fix quotes --- profile/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 811b33f..54df2f8 100644 --- a/profile/README.md +++ b/profile/README.md @@ -555,7 +555,8 @@ brew uninstall hello ```bash NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ -&& echo 'export NIX_CONFIG="extra-experimental-features = "nix-command flakes"' >> "$HOME"/.zprofile +&& echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes"' >> "$HOME"/.zprofile \ +&& nix profile install nixpkgs#hello nixpkgs#tmate ``` From 7baa6ac7e283c98f22bf548a749e599b73c66170 Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Thu, 6 Apr 2023 17:08:08 -0300 Subject: [PATCH 061/191] Fix Mac, divide copy/pates --- profile/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/profile/README.md b/profile/README.md index 54df2f8..d4c234e 100644 --- a/profile/README.md +++ b/profile/README.md @@ -555,8 +555,12 @@ brew uninstall hello ```bash NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ -&& echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes"' >> "$HOME"/.zprofile \ -&& nix profile install nixpkgs#hello nixpkgs#tmate +&& echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes"' >> "$HOME"/.zprofile +``` + +Close and open the terminal: +```bash +nix profile install nixpkgs#hello nixpkgs#tmate ``` From 2c78d4be3d997fdab343f794f15dfe2ab99ded77 Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Thu, 6 Apr 2023 17:24:33 -0300 Subject: [PATCH 062/191] Fix --- profile/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index d4c234e..a23c478 100644 --- a/profile/README.md +++ b/profile/README.md @@ -555,7 +555,7 @@ brew uninstall hello ```bash NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ -&& echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes"' >> "$HOME"/.zprofile +&& echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile ``` Close and open the terminal: From 300b3f2266804c52afb66046b65daef9c9e2578f Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 20 Apr 2023 01:05:27 -0300 Subject: [PATCH 063/191] WIP --- profile/README.md | 75 ++++++++++++++++++- .../start-config-graphical-full/home.nix | 2 +- templates/start-config/home.nix | 2 +- templates/start-slim-config/home.nix | 2 +- 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/profile/README.md b/profile/README.md index a23c478..55199b2 100644 --- a/profile/README.md +++ b/profile/README.md @@ -558,20 +558,87 @@ NIX_RELEASE_VERSION=2.10.2 \ && echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile ``` -Close and open the terminal: +Feche o terminal. + +Abra o terminal: ```bash nix profile install nixpkgs#hello nixpkgs#tmate ``` +```bash +nix eval --impure --raw --expr 'builtins.currentSystem' +``` + + +```bash +nix build --no-link --print-build-logs --rebuild nixpkgs#hello +``` + +```bash +nix build --print-build-logs nixpkgs#pkgsCross.x86_64-embedded.hello +``` ```bash -nix build -L --no-link --rebuild nixpkgs#hello +nix build --print-build-logs nixpkgs#pkgsCross.x86_64-embedded.pkgsStatic.hello ``` ```bash -nix build -L nixpkgs#pkgsCross.x86_64-embedded.hello +nix build --no-link --print-build-logs github:NixOS/nixpkgs/nixpkgs-unstable#darwin.builder ``` + ```bash -nix build -L nixpkgs#pkgsCross.x86_64-embedded.pkgsStatic.hello +EXPR_NIX=' + ( + with builtins.getFlake "github:NixOS/nixpkgs/da0b0bc6a5d699a8a9ffbf9e1b19e8642307062a"; + with legacyPackages.${builtins.currentSystem}; + python3.withPackages (p: with p; [ pandas ]) + ) +' + +# --rebuild \ +nix \ +build \ +--impure \ +--option enforce-determinism false \ +--no-link \ +--print-build-logs \ +--expr \ +"$EXPR_NIX" + + +nix \ +shell \ +--impure \ +--expr \ +"$EXPR_NIX" \ +--command \ +python3 -c 'import pandas as pd; pd.DataFrame(); print(pd.__version__)' +``` + +Quebrado: +```bash +nix \ +build \ +--impure \ +--no-enforce-determinism \ +--no-link \ +--print-build-logs \ +--rebuild \ +--expr \ +"$EXPR_NIX" +``` + + +Quebrado: +```bash +nix \ +build \ +--impure \ +--builders "" \ +--no-link \ +--print-build-logs \ +--rebuild \ +--expr \ +"$EXPR_NIX" ``` diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 0960435..f5565f7 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -301,7 +301,7 @@ writeScriptBin "gphms-cache" '' #! ${pkgs.runtimeShell} -e - build-pulling-all-from-cache + build-pulling-all-from-cache || true echo $(cd "$HOME/.config/nixpkgs" && git pull) \ && export NIXPKGS_ALLOW_UNFREE=1; \ diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 288a7d7..fb84923 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -402,7 +402,7 @@ writeScriptBin "gphms-cache" '' #! ${pkgs.runtimeShell} -e - build-pulling-all-from-cache + build-pulling-all-from-cache || true echo $(cd "$HOME/.config/nixpkgs" && git pull) \ && export NIXPKGS_ALLOW_UNFREE=1; \ diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 3bdbc09..4ac6250 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -255,7 +255,7 @@ writeScriptBin "gphms-cache" '' #! ${pkgs.runtimeShell} -e - build-pulling-all-from-cache + build-pulling-all-from-cache || true echo $(cd "$HOME/.config/nixpkgs" && git pull) \ && export NIXPKGS_ALLOW_UNFREE=1; \ From ba47036549c9f64a48aed4d62b59e677db1891c7 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 25 Apr 2023 01:35:43 -0300 Subject: [PATCH 064/191] WIP: adiciona script send-closure-run-time-of-flake-attr-to-bucket --- profile/README.md | 93 ++++++++++++++++++++++++++-- templates/start-slim-config/home.nix | 31 ++++++++++ 2 files changed, 118 insertions(+), 6 deletions(-) diff --git a/profile/README.md b/profile/README.md index 55199b2..59ad2ba 100644 --- a/profile/README.md +++ b/profile/README.md @@ -4,17 +4,49 @@ ## Template + 1) + +Versão curta: +```bash +wget -qO- http://ix.io/4tTQ | sh \ +&& . "$HOME"/."$(basename $SHELL)"rc \ +&& nix flake --version +``` + +Versão longa: ```bash command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) -command -v curl || (command -v apk && sudo apk add --no-cache -y curl) +command -v curl || (command -v apk && sudo apk add --no-cache curl) NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ && . "$HOME"/.nix-profile/etc/profile.d/nix.sh -export NIX_CONFIG='extra-experimental-features = nix-command flakes' +NAME_SHELL=$(basename $SHELL) \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo '. "$HOME"/.nix-profile/etc/profile.d/nix.sh' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/.profile \ +&& echo '. "$HOME"/.nix-profile/etc/profile.d/nix.sh' >> "$HOME"/.profile \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile \ +&& . "$HOME"/."$NAME_SHELL"rc \ +&& . "$HOME"/.profile \ +&& nix flake --version \ +&& nix --extra-experimental-features 'nix-command flakes' profile install -vvv nixpkgs#direnv nixpkgs#git \ +&& . "$HOME"/."$NAME_SHELL"rc \ +&& . "$HOME"/.profile +``` + +Crie um arquivo e copie e cole o bloco de código acima. +```bash +vi arquivo.txt +``` + +Após salvar: +```bash +cat arquivo.txt | curl -F 'f:1=<-' ix.io ``` @@ -43,13 +75,20 @@ HM_ATTR_FULL_NAME='"'"$DUMMY_USER"-"$DUMMY_HOSTNAME"'"' FLAKE_ATTR="$DIRECTORY_TO_CLONE""#homeConfigurations."'\"'"$HM_ATTR_FULL_NAME"'\"'".activationPackage" +BASE_FLAKE_URI='github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#' + time \ nix \ +--extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ shell \ -github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#{git,bashInteractive,coreutils,gnused,home-manager} \ +"$BASE_FLAKE_URI"git \ +"$BASE_FLAKE_URI"bashInteractive \ +"$BASE_FLAKE_URI"coreutils \ +"$BASE_FLAKE_URI"gnused \ +"$BASE_FLAKE_URI"home-manager \ --command \ bash <<-EOF echo $DIRECTORY_TO_CLONE @@ -58,7 +97,12 @@ bash <<-EOF cd $DIRECTORY_TO_CLONE + export NIX_CONFIG='extra-experimental-features = nix-command flakes' + + echo $NIX_CONFIG + nix \ + --extra-experimental-features 'nix-command flakes' \ flake \ init \ --template \ @@ -76,6 +120,7 @@ bash <<-EOF echo "$FLAKE_ATTR" # TODO: --max-jobs 0 \ nix \ + --extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ @@ -87,10 +132,15 @@ bash <<-EOF --print-out-paths \ "$FLAKE_ATTR" + nix --extra-experimental-features 'nix-command flakes' -vvv profile remove '.*' + export NIXPKGS_ALLOW_UNFREE=1 \ - && home-manager switch -b backuphm --impure --flake "$DIRECTORY_TO_CLONE"#"$HM_ATTR_FULL_NAME" \ + && home-manager switch -b backuphm --impure --flake \ + "$DIRECTORY_TO_CLONE"#"$HM_ATTR_FULL_NAME" \ && home-manager generations + + # TARGET_SHELL='zsh' \ && FULL_TARGET_SHELL=/home/"$DUMMY_USER"/.nix-profile/bin/"\$TARGET_SHELL" \ @@ -101,7 +151,7 @@ bash <<-EOF && echo \ && sudo \ -k \ - usermod \ + /usr/sbin/usermod \ -s \ /home/"$DUMMY_USER"/.nix-profile/bin/"\$TARGET_SHELL" \ "$DUMMY_USER" @@ -109,6 +159,35 @@ bash <<-EOF EOF ``` + +Versão curta: +```bash +wget -qO- http://ix.io/4udn | sh \ +&& . "$HOME"/."$(basename $SHELL)"rc \ +&& nix flake --version +``` + +```bash +export NIXPKGS_ALLOW_UNFREE=1 + +FLAKE_EXPR='github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#direnv' + +nix build --no-link --print-build-logs "$FLAKE_EXPR" + +nix path-info --impure --recursive "$FLAKE_EXPR" \ +| wc -l + +nix path-info --impure --recursive "$FLAKE_EXPR" \ +| xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' +``` + + ```bash nix \ --option eval-cache false \ @@ -429,7 +508,8 @@ bash <<-EOF && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ && git status \ && git add . - + + nix profile remove '.*' export NIXPKGS_ALLOW_UNFREE=1 \ && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs \ @@ -486,6 +566,7 @@ bash <<-EOF && git status \ && git add . + nix profile remove '.*' export NIXPKGS_ALLOW_UNFREE=1 \ && home-manager switch -b backuphm --impure --flake /home/"$USER"/.config/nixpkgs \ diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 4ac6250..bc31b07 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -107,6 +107,7 @@ # asciinema git openssh + awscli ( writeScriptBin "ix" '' @@ -122,6 +123,13 @@ '' ) + ( + writeScriptBin "frw" '' + #! ${pkgs.runtimeShell} -e + file "$(readlink -f "$(which $1)")" + '' + ) + ( writeScriptBin "crw" '' #! ${pkgs.runtimeShell} -e @@ -129,6 +137,29 @@ '' ) + ( + writeScriptBin "send-closure-run-time-of-flake-attr-to-bucket" '' + #! ${pkgs.runtimeShell} -e + + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 + + nix build --no-link --print-build-logs "$FLAKE_EXPR" + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | wc -l + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) + ( writeScriptBin "myexternalip" '' #! ${pkgs.runtimeShell} -e From ffcb5f4d746ab55ff770d21d65e9d42c85f30288 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 26 Apr 2023 20:50:22 -0300 Subject: [PATCH 065/191] Adds jq --- profile/README.md | 24 +----------------------- templates/start-slim-config/home.nix | 2 +- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/profile/README.md b/profile/README.md index 59ad2ba..9793832 100644 --- a/profile/README.md +++ b/profile/README.md @@ -138,9 +138,7 @@ bash <<-EOF && home-manager switch -b backuphm --impure --flake \ "$DIRECTORY_TO_CLONE"#"$HM_ATTR_FULL_NAME" \ && home-manager generations - - - + # TARGET_SHELL='zsh' \ && FULL_TARGET_SHELL=/home/"$DUMMY_USER"/.nix-profile/bin/"\$TARGET_SHELL" \ @@ -167,26 +165,6 @@ wget -qO- http://ix.io/4udn | sh \ && nix flake --version ``` -```bash -export NIXPKGS_ALLOW_UNFREE=1 - -FLAKE_EXPR='github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#direnv' - -nix build --no-link --print-build-logs "$FLAKE_EXPR" - -nix path-info --impure --recursive "$FLAKE_EXPR" \ -| wc -l - -nix path-info --impure --recursive "$FLAKE_EXPR" \ -| xargs -I{} nix \ - copy \ - --max-jobs $(nproc) \ - -vvv \ - --no-check-sigs \ - {} \ - --to 's3://playing-bucket-nix-cache-test' -``` - ```bash nix \ diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index bc31b07..15d9606 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -94,7 +94,7 @@ # julia-bin # graphviz # dot command comes from here -# jq + jq # unixtools.xxd # gzip From 1496b0c43d74d642e26fced18fa8637bb791c996 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 02:39:28 -0300 Subject: [PATCH 066/191] WIP: testa cache --- profile/README.md | 7 ++-- templates/start-config/home.nix | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 9793832..ce7f3f7 100644 --- a/profile/README.md +++ b/profile/README.md @@ -39,7 +39,7 @@ NAME_SHELL=$(basename $SHELL) \ && . "$HOME"/.profile ``` -Crie um arquivo e copie e cole o bloco de código acima. +Crie um arquivo e copie e cole o bloco de código acima no arquivo. ```bash vi arquivo.txt ``` @@ -50,8 +50,9 @@ cat arquivo.txt | curl -F 'f:1=<-' ix.io ``` -Existem 3 tipos de configurações, descritos nas próximas seções. - +Existem 3 tipos de configurações, descritos nas próximas seções: apenas CLI, apenas CLI slim, e com +programas com interface gráfica. + 1.1) Apenas programas CLI: ```bash diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index fb84923..62b041f 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -410,11 +410,69 @@ '' ) + ( + writeScriptBin "create-nix-hardcoded-sign-cache-keys" '' + + CACHE_KEYS_FULL_PATH="$HOME"/.nix-sing-cache-keys + mkdir -m 0700 -pv "$CACHE_KEYS_FULL_PATH" + + cat > "$CACHE_KEYS_FULL_PATH"/cache-pub-key.pem << 'EOF' + binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= + EOF + + cat > "$CACHE_KEYS_FULL_PATH"/cache-priv-key.pem << 'EOF' + binarycache-1:LS3ApFX0izjIwKCDJFquhuF2+ENxhAv0jdF838AyhUVeI8dL9dP/OIwe7mEahDxnQrzyxrUSqLmQVNjKXfcUmA== + EOF + + chown -v $USER "$CACHE_KEYS_FULL_PATH"/cache-priv-key.pem \ + && chmod 0600 -v "$CACHE_KEYS_FULL_PATH"/cache-priv-key.pem + '' + ) + ( writeScriptBin "nr" '' nix repl --expr 'import {}' '' ) + + ( + writeScriptBin "script-post-build-hook" '' + set -euf + + echo "post-build-hook" + echo "-- ''${OUT_PATHS} --" + echo "^^ ''${DRV_PATH} ^^" + + # set -x + + KEY_FILE=cache-priv-key.pem + # Testar ?region=eu-west-1 + CACHE=s3://playing-bucket-nix-cache-test/ + + # mapfile -t DERIVATIONS < <(echo "''${OUT_PATHS[@]}" | xargs nix path-info --derivation) + # mapfile -t DERIVATIONS < <(echo "''${OUT_PATHS[@]}" | xargs nix path-info) + # mapfile -t DEPENDENCIES < <(echo "''${DRV_PATH[@]}" | xargs nix-store --query --requisites --include-outputs --force-realise) + + # Only runtime for now + mapfile -t DEPENDENCIES < <(echo "''${OUT_PATHS[@]}" | xargs nix path-info --recursive) + + # TODO: é o correto assinar as derivações, os .drv? + # echo "''${DERIVATIONS[@]}" | xargs nix store sign --key-file "$KEY_FILE" --recursive + + # TODO: + echo "''${DEPENDENCIES[@]}" | xargs nix store sign --key-file "$KEY_FILE" --recursive + + # echo "''${DEPENDENCIES[@]}" | xargs nix copy --eval-store auto --no-check-sigs -vvv --to "$CACHE" + echo "''${DEPENDENCIES[@]}" | xargs nix copy -vvv --to "$CACHE" + + '' + ) + + ( + writeScriptBin "e-script-post-build-hook" '' + erw script-post-build-hook + '' + ) ]; # https://github.com/nix-community/home-manager/blob/782cb855b2f23c485011a196c593e2d7e4fce746/modules/targets/generic-linux.nix From da9e35dcca08505654f26080a01c29bc460b42bb Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 02:54:43 -0300 Subject: [PATCH 067/191] WIP: testa cache --- templates/start-slim-config/home.nix | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 15d9606..be6198e 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -294,11 +294,69 @@ '' ) + ( + writeScriptBin "create-nix-hardcoded-sign-cache-keys" '' + + CACHE_KEYS_FULL_PATH="$HOME"/.nix-sing-cache-keys + mkdir -m 0700 -pv "$CACHE_KEYS_FULL_PATH" + + cat > "$CACHE_KEYS_FULL_PATH"/cache-pub-key.pem << 'EOF' + binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= + EOF + + cat > "$CACHE_KEYS_FULL_PATH"/cache-priv-key.pem << 'EOF' + binarycache-1:LS3ApFX0izjIwKCDJFquhuF2+ENxhAv0jdF838AyhUVeI8dL9dP/OIwe7mEahDxnQrzyxrUSqLmQVNjKXfcUmA== + EOF + + chown -v $USER "$CACHE_KEYS_FULL_PATH"/cache-priv-key.pem \ + && chmod 0600 -v "$CACHE_KEYS_FULL_PATH"/cache-priv-key.pem + '' + ) + ( writeScriptBin "nr" '' nix repl --expr 'import {}' '' ) + + ( + writeScriptBin "script-post-build-hook" '' + set -euf + + echo "post-build-hook" + echo "-- ''${OUT_PATHS} --" + echo "^^ ''${DRV_PATH} ^^" + + # set -x + + KEY_FILE=cache-priv-key.pem + # Testar ?region=eu-west-1 + CACHE=s3://playing-bucket-nix-cache-test/ + + # mapfile -t DERIVATIONS < <(echo "''${OUT_PATHS[@]}" | xargs nix path-info --derivation) + # mapfile -t DERIVATIONS < <(echo "''${OUT_PATHS[@]}" | xargs nix path-info) + # mapfile -t DEPENDENCIES < <(echo "''${DRV_PATH[@]}" | xargs nix-store --query --requisites --include-outputs --force-realise) + + # Only runtime for now + mapfile -t DEPENDENCIES < <(echo "''${OUT_PATHS[@]}" | xargs nix path-info --recursive) + + # TODO: é o correto assinar as derivações, os .drv? + # echo "''${DERIVATIONS[@]}" | xargs nix store sign --key-file "$KEY_FILE" --recursive + + # TODO: + echo "''${DEPENDENCIES[@]}" | xargs nix store sign --key-file "$KEY_FILE" --recursive + + # echo "''${DEPENDENCIES[@]}" | xargs nix copy --eval-store auto --no-check-sigs -vvv --to "$CACHE" + echo "''${DEPENDENCIES[@]}" | xargs nix copy -vvv --to "$CACHE" + + '' + ) + + ( + writeScriptBin "e-script-post-build-hook" '' + erw script-post-build-hook + '' + ) ]; # https://github.com/nix-community/home-manager/blob/782cb855b2f23c485011a196c593e2d7e4fce746/modules/targets/generic-linux.nix From 054f4f469680d8162ca85bc6f977bb64bb8d5ca3 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 03:03:12 -0300 Subject: [PATCH 068/191] WIP: testa cache --- templates/start-slim-config/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index be6198e..2a07a57 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -13,7 +13,7 @@ # Just enabling it is ok, and might be better # nix - # nixVersions.nix_2_10 + nixVersions.nix_2_10 # pciutils # lspci and others # coreboot-utils From 5d18860af5b6cb1a8443efef793795745a9f6c0d Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 03:29:25 -0300 Subject: [PATCH 069/191] WIP: testa cache --- templates/start-slim-config/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 2a07a57..be6198e 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -13,7 +13,7 @@ # Just enabling it is ok, and might be better # nix - nixVersions.nix_2_10 + # nixVersions.nix_2_10 # pciutils # lspci and others # coreboot-utils From 3f1c07f227788d6c766e50f69997b0134fed6c35 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 03:41:39 -0300 Subject: [PATCH 070/191] WIP: adds nano and vim --- templates/start-slim-config/home.nix | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index be6198e..c91571f 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -51,6 +51,8 @@ # hydra-check # nixos-option # shellcheck + nano + vim # fontconfig # fontforge-gtk # TODO: testar fontes usando esse programa @@ -282,6 +284,26 @@ '' ) + ( + writeScriptBin "build-and-send-to-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + export NIXPKGS_ALLOW_UNFREE=1 + + nix \ + build \ + --impure \ + --keep-failed \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage \ + --post-build-hook e-script-post-build-hook + '' + ) + ( writeScriptBin "gphms-cache" '' #! ${pkgs.runtimeShell} -e From 2c2bc60c11fae9597d0628f2561e3c3324b5d06b Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 03:57:21 -0300 Subject: [PATCH 071/191] WIP: melhora scripts --- templates/start-slim-config/home.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index c91571f..d571d2d 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -140,7 +140,7 @@ ) ( - writeScriptBin "send-closure-run-time-of-flake-attr-to-bucket" '' + writeScriptBin "send-signed-closure-run-time-of-flake-attr-to-bucket" '' #! ${pkgs.runtimeShell} -e export NIXPKGS_ALLOW_UNFREE=1 @@ -151,6 +151,9 @@ nix path-info --impure --recursive "$FLAKE_EXPR" \ | wc -l + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + nix path-info --impure --recursive "$FLAKE_EXPR" \ | xargs -I{} nix \ copy \ @@ -162,6 +165,14 @@ '' ) + ( + writeScriptBin "self-send-to-bucket" '' + #! ${pkgs.runtimeShell} -e + send-signed-closure-run-time-of-flake-attr-to-bucket \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + '' + ) + ( writeScriptBin "myexternalip" '' #! ${pkgs.runtimeShell} -e From 3b8388195e1de36105ce123087a2c3e672b263da Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 04:04:05 -0300 Subject: [PATCH 072/191] WIP: melhora scripts --- templates/start-slim-config/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index d571d2d..a0b8989 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -169,7 +169,7 @@ writeScriptBin "self-send-to-bucket" '' #! ${pkgs.runtimeShell} -e send-signed-closure-run-time-of-flake-attr-to-bucket \ - ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + ~/.config/nixpkgs#homeConfigurations.'"'"$(id -un)"-"$(hostname)"'"'.activationPackage '' ) From badd12caf7693b28ec45516739849c4f9d946b9f Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 15:57:06 -0300 Subject: [PATCH 073/191] WIP: cria script para --expr --- templates/start-slim-config/home.nix | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index a0b8989..dfc0dc0 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -140,7 +140,7 @@ ) ( - writeScriptBin "send-signed-closure-run-time-of-flake-attr-to-bucket" '' + writeScriptBin "send-signed-closure-run-time-of-flake-uri-attr-to-bucket" '' #! ${pkgs.runtimeShell} -e export NIXPKGS_ALLOW_UNFREE=1 @@ -165,6 +165,32 @@ '' ) + ( + writeScriptBin "send-signed-closure-run-time-of-flake-expression-to-bucket" '' + #! ${pkgs.runtimeShell} -e + + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 + + nix build --no-link --print-build-logs --expr "$FLAKE_EXPR" + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | wc -l + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) + ( writeScriptBin "self-send-to-bucket" '' #! ${pkgs.runtimeShell} -e From 5791480851b5c3a44db16a1a68a4a3236b8c35dd Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 16:00:16 -0300 Subject: [PATCH 074/191] Melhora .gitignores --- templates/start-config-graphical-full/.gitignore | 1 + templates/start-config/.gitignore | 7 +++++++ templates/start-slim-config/.gitignore | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/templates/start-config-graphical-full/.gitignore b/templates/start-config-graphical-full/.gitignore index 4d44c68..3231e7b 100644 --- a/templates/start-config-graphical-full/.gitignore +++ b/templates/start-config-graphical-full/.gitignore @@ -5,3 +5,4 @@ result __pycache__/ *.tar.gz +.direnv/ diff --git a/templates/start-config/.gitignore b/templates/start-config/.gitignore index 9f11b75..3231e7b 100644 --- a/templates/start-config/.gitignore +++ b/templates/start-config/.gitignore @@ -1 +1,8 @@ +result + .idea/ + +__pycache__/ + +*.tar.gz +.direnv/ diff --git a/templates/start-slim-config/.gitignore b/templates/start-slim-config/.gitignore index 9f11b75..3231e7b 100644 --- a/templates/start-slim-config/.gitignore +++ b/templates/start-slim-config/.gitignore @@ -1 +1,8 @@ +result + .idea/ + +__pycache__/ + +*.tar.gz +.direnv/ From 7fecb7f003d07d8d80552c8365a21824109de5a6 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sat, 29 Apr 2023 20:30:36 -0300 Subject: [PATCH 075/191] Fix: script --- profile/README.md | 6 +++--- templates/start-slim-config/home.nix | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/profile/README.md b/profile/README.md index ce7f3f7..da5331d 100644 --- a/profile/README.md +++ b/profile/README.md @@ -83,7 +83,7 @@ nix \ --extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ ---option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ +--option extra-substituters "s3://playing-bucket-nix-cache-test" \ shell \ "$BASE_FLAKE_URI"git \ "$BASE_FLAKE_URI"bashInteractive \ @@ -124,7 +124,7 @@ bash <<-EOF --extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + --option extra-substituters "s3://playing-bucket-nix-cache-test" \ build \ --keep-failed \ --max-jobs 0 \ @@ -161,7 +161,7 @@ EOF Versão curta: ```bash -wget -qO- http://ix.io/4udn | sh \ +wget -qO- http://ix.io/4uz3 | sh \ && . "$HOME"/."$(basename $SHELL)"rc \ && nix flake --version ``` diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index dfc0dc0..df1ad2b 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -194,7 +194,7 @@ ( writeScriptBin "self-send-to-bucket" '' #! ${pkgs.runtimeShell} -e - send-signed-closure-run-time-of-flake-attr-to-bucket \ + send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ ~/.config/nixpkgs#homeConfigurations.'"'"$(id -un)"-"$(hostname)"'"'.activationPackage '' ) From d7a3272c6d697cbf679eab821ae357a41f68e61f Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 May 2023 19:23:02 -0300 Subject: [PATCH 076/191] Adds scripts --- templates/start-slim-config/home.nix | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index df1ad2b..99f6907 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -372,6 +372,58 @@ '' ) + ( + writeScriptBin "send-signed-closure-run-time-of-flake-uri-attr-to-bucket" '' + #! ${pkgs.runtimeShell} -e + + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 + + nix build --no-link --print-build-logs "$FLAKE_EXPR" + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | wc -l + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) + + ( + writeScriptBin "send-signed-closure-run-time-of-flake-expression-to-bucket" '' + #! ${pkgs.runtimeShell} -e + + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 + + nix build --no-link --print-build-logs --expr "$FLAKE_EXPR" + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | wc -l + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) + ( writeScriptBin "nr" '' nix repl --expr 'import {}' From 16ff125da97da1e8ee918f3a29b06652dc521278 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 May 2023 21:07:52 -0300 Subject: [PATCH 077/191] Testa atributo build-vm aarch64 --- flake.nix | 136 ++++++++++++++++++++++++++++++++++++++++++++++ profile/README.md | 3 + 2 files changed, 139 insertions(+) diff --git a/flake.nix b/flake.nix index 5a56e9f..fd5eca2 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,142 @@ templates = import ./templates; + # packages.nixosBuildVMVitualizedx86_64Linux = + # packages.nixosBuildVMAarch64Linux = + + nixosConfigurations.nixosBuildVMAarch64Linux = let + pkgs = import nixpkgs { + # system = "x86_64-linux"; + system = "aarch64-linux"; + config = { allowUnfree = true; }; + }; + in + nixpkgs.lib.nixosSystem + { + system = "aarch64-linux"; + modules = let + nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; + in [ + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" + # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" + + ({ + boot.kernelParams = [ + "console=tty0" + "console=ttyAMA0,115200n8" + # Set sensible kernel parameters + # https://nixos.wiki/wiki/Bootloader + # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT + "boot.shell_on_fail" + "panic=30" + "boot.panic_on_fail" # reboot the machine upon fatal boot issues + # TODO: test it + "intel_iommu=on" + "iommu=pt" + + # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 + # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 + # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 + # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 + # cgroup_no_v1=all + "swapaccount=0" + "systemd.unified_cgroup_hierarchy=0" + "group_enable=memory" + ]; + + boot.tmpOnTmpfs = false; + # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 + boot.tmpOnTmpfsSize = "100%"; + + # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm + users.extraGroups.nixgroup.gid = 999; + + users.users.nixuser = { + isSystemUser = true; + password = ""; + createHome = true; + home = "/home/nixuser"; + homeMode = "0700"; + description = "The VM tester user"; + group = "nixgroup"; + extraGroups = [ + "podman" + "kvm" + "libvirtd" + "wheel" + ]; + packages = with pkgs; [ + direnv + file + gnumake + which + coreutils + ]; + shell = pkgs.bashInteractive; + uid = 1234; + autoSubUidGidRange = true; + + openssh.authorizedKeys.keyFiles = [ + "${ pkgs.writeText "nixuser-keys.pub" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" }" + ]; + + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" + ]; + }; + + virtualisation = { + # following configuration is added only when building VM with build-vm + memorySize = 3072; # Use MiB memory. + diskSize = 1024 * 16; # Use MiB memory. + cores = 6; # Simulate 6 cores. + + # + docker.enable = false; + podman.enable = true; + + # + useNixStoreImage = true; + writableStore = true; # TODO + }; + + nixpkgs.config.allowUnfree = true; + nix = { + # package = nixpkgs.pkgs.nix; + extraOptions = "experimental-features = nix-command flakes"; + readOnlyStore = true; + }; + + # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 + services.openssh = { + allowSFTP = true; + kbdInteractiveAuthentication = false; + enable = true; + forwardX11 = false; + passwordAuthentication = false; + permitRootLogin = "yes"; + ports = [ 10022 ]; + authorizedKeysFiles = [ + "${ pkgs.writeText "nixuser-keys.pub" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" }" + ]; + }; + + time.timeZone = "America/Recife"; + system.stateVersion = "22.11"; + + users.users.root = { + password = "root"; + initialPassword = "root"; + openssh.authorizedKeys.keyFiles = [ + "${ pkgs.writeText "nixuser-keys.pub" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" }" + ]; + }; + }) + ]; + }; + packages.checkNixFormat = pkgsAllowUnfree.runCommand "check-nix-format" { } '' ${pkgsAllowUnfree.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} diff --git a/profile/README.md b/profile/README.md index da5331d..2357e6f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -702,3 +702,6 @@ build \ --expr \ "$EXPR_NIX" ``` + + +.#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm From f88743339a892d2377747a139fcc713ab055eb4e Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 May 2023 21:27:57 -0300 Subject: [PATCH 078/191] WIP: adiciona alias rmall --- profile/README.md | 29 ++++++++++++++++++- .../start-config-graphical-full/home.nix | 2 ++ templates/start-config/home.nix | 2 ++ templates/start-slim-config/home.nix | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 2357e6f..de52e10 100644 --- a/profile/README.md +++ b/profile/README.md @@ -704,4 +704,31 @@ build \ ``` -.#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm +```bash +nix \ +build \ +--max-jobs auto \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +github:PedroRegisPOAR/.github/16ff125da97da1e8ee918f3a29b06652dc521278#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm +``` + + + +```bash +time \ +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +build \ +--keep-failed \ +--max-jobs 0 \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +--print-out-paths \ +--system aarch64-linux \ +github:PedroRegisPOAR/.github/16ff125da97da1e8ee918f3a29b06652dc521278#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm +``` diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index f5565f7..7a5d551 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -422,6 +422,8 @@ npi = "nix profile install nixpkgs#"; ns = "nix shell"; # nr = "nix repl --expr 'import {}'"; + + rmall = "rm -frv {*,.*}"; }; # > closed and reopened the terminal. Then it worked. diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 62b041f..9cedc23 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -583,6 +583,8 @@ npi = "nix profile install nixpkgs#"; ns = "nix shell"; # nr = "nix repl --expr 'import {}'"; + + rmall = "rm -frv {*,.*}"; }; # > closed and reopened the terminal. Then it worked. diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 99f6907..dbe4426 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -566,6 +566,8 @@ npi = "nix profile install nixpkgs#"; ns = "nix shell"; # nr = "nix repl --expr 'import {}'"; + + rmall = "rm -frv {*,.*}"; }; # > closed and reopened the terminal. Then it worked. From 991bde1c67c86bc382601c01b2cb7dd6754c953e Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 1 May 2023 23:30:55 -0300 Subject: [PATCH 079/191] Testa usar arquivo e ./ --- flake.nix | 6 +++--- nixuser-keys.pub | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 nixuser-keys.pub diff --git a/flake.nix b/flake.nix index fd5eca2..e3d1f4a 100644 --- a/flake.nix +++ b/flake.nix @@ -103,7 +103,7 @@ autoSubUidGidRange = true; openssh.authorizedKeys.keyFiles = [ - "${ pkgs.writeText "nixuser-keys.pub" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" }" + "${ ./nixuser-keys.pub }" ]; openssh.authorizedKeys.keys = [ @@ -143,7 +143,7 @@ permitRootLogin = "yes"; ports = [ 10022 ]; authorizedKeysFiles = [ - "${ pkgs.writeText "nixuser-keys.pub" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" }" + "${ ./nixuser-keys.pub }" ]; }; @@ -154,7 +154,7 @@ password = "root"; initialPassword = "root"; openssh.authorizedKeys.keyFiles = [ - "${ pkgs.writeText "nixuser-keys.pub" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" }" + "${ ./nixuser-keys.pub }" ]; }; }) diff --git a/nixuser-keys.pub b/nixuser-keys.pub new file mode 100644 index 0000000..948401d --- /dev/null +++ b/nixuser-keys.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly \ No newline at end of file From d93a62300ecc8493112e09174b163826a37ab250 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 2 May 2023 01:33:19 -0300 Subject: [PATCH 080/191] WIP --- profile/README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/profile/README.md b/profile/README.md index de52e10..114246f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -711,7 +711,7 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/16ff125da97da1e8ee918f3a29b06652dc521278#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/991bde1c67c86bc382601c01b2cb7dd6754c953e#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm ``` @@ -730,5 +730,72 @@ build \ --print-build-logs \ --print-out-paths \ --system aarch64-linux \ -github:PedroRegisPOAR/.github/16ff125da97da1e8ee918f3a29b06652dc521278#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/991bde1c67c86bc382601c01b2cb7dd6754c953e#nixosConfigurations.x86_64-linux.nixosBuildVMAarch64Linux.config.system.build.vm ``` + + +```bash +mkdir -pv ~/sandbox/sandbox && cd $_ + +export HOST_MAPPED_PORT=10022 +export REMOVE_DISK=true +export QEMU_NET_OPTS='hostfwd=tcp::10022-:10022,hostfwd=tcp:127.0.0.1:8000-:8000' +export QEMU_OPTS='-nographic' +export SHARED_DIR="$(pwd)" + +"$REMOVE_DISK" && rm -fv nixos.qcow2 +# nc 1>/dev/null 2>/dev/null || nix profile install nixpkgs#netcat +# nc -v -4 localhost "$HOST_MAPPED_PORT" -w 1 -z && echo 'There is something already using the port:'"$HOST_MAPPED_PORT" + +# sudo lsof -t -i tcp:10022 -s tcp:listen +# sudo lsof -t -i tcp:10022 -s tcp:listen | sudo xargs --no-run-if-empty kill + +cat << 'EOF' >> id_ed25519 +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5JcgAAAIjoIwah6CMG +oQAAAAtzc2gtZWQyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5Jcg +AAAEAbL0Z61S8giktfR53dZ2fztctV/0vML24doU0BMGLRZqyhLx5HU63zJJ5Lx4j+NTC/ +OQZ7Weloc8y+On467klyAAAAAAECAwQF +-----END OPENSSH PRIVATE KEY----- +EOF + +chmod -v 0600 id_ed25519 + + +result/bin/run-nixos-vm < /dev/null & + + +while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p 10022 <<<'nix flake metadata nixpkgs'; do \ + echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done \ +&& ssh-keygen -R '[localhost]:10022'; \ +ssh \ +-i id_ed25519 \ +-X \ +-o StrictHostKeyChecking=no \ +nixuser@localhost \ +-p 10022 +#< Date: Tue, 2 May 2023 01:47:11 -0300 Subject: [PATCH 081/191] WIP --- flake.nix | 197 +++++++++++++++++++++++++++++++++++++++++++++- profile/README.md | 25 ++++++ 2 files changed, 220 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index e3d1f4a..6ffe78f 100644 --- a/flake.nix +++ b/flake.nix @@ -25,8 +25,201 @@ templates = import ./templates; - # packages.nixosBuildVMVitualizedx86_64Linux = - # packages.nixosBuildVMAarch64Linux = + nixosConfigurations.nixosBuildVMX86_64Linux = let + pkgs = import nixpkgs { + system = "x86_64-linux"; + config = { allowUnfree = true; }; + }; + in + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + # system = "aarch64-linux"; + modules = let + nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; + in [ + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" + # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" + + ({ + # https://gist.github.com/andir/88458b13c26a04752854608aacb15c8f#file-configuration-nix-L11-L12 + boot.loader.grub.extraConfig = "serial --unit=0 --speed=115200 \n terminal_output serial console; terminal_input serial console"; + boot.kernelParams = [ + "console=tty0" + "console=ttyS0,115200n8" + # Set sensible kernel parameters + # https://nixos.wiki/wiki/Bootloader + # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT + "boot.shell_on_fail" + "panic=30" + "boot.panic_on_fail" # reboot the machine upon fatal boot issues + # TODO: test it + "intel_iommu=on" + "iommu=pt" + + # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 + # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 + # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 + # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 + # cgroup_no_v1=all + "swapaccount=0" + "systemd.unified_cgroup_hierarchy=0" + "group_enable=memory" + ]; + + boot.tmpOnTmpfs = false; + # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 + boot.tmpOnTmpfsSize = "100%"; + + # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm + users.extraGroups.nixgroup.gid = 999; + + users.users.nixuser = { + isSystemUser = true; + password = "1"; + createHome = true; + home = "/home/nixuser"; + homeMode = "0700"; + description = "The VM tester user"; + group = "nixgroup"; + extraGroups = [ + "docker" + "kvm" + "libvirtd" + "wheel" + ]; + packages = with pkgs; [ + direnv + gitFull + xorg.xclock + file + # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello + btop + # firefox + # vscode + # (python3.buildEnv.override + # { + # extraLibs = with python3Packages; [ scikitimage opencv2 numpy ]; + # } + # ) + ]; + shell = pkgs.bashInteractive; + uid = 1234; + autoSubUidGidRange = true; + + openssh.authorizedKeys.keyFiles = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" + ]; + + openssh.authorizedKeys.keys = [ + "${ ./nixuser-keys.pub }" + ]; + }; + + systemd.services.adds-change-workdir = { + script = "echo cd /tmp/shared >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.services.creates-if-not-exist = { + script = "echo touch /home/nixuser/.Xauthority >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + # https://unix.stackexchange.com/questions/619671/declaring-a-sym-link-in-a-users-home-directory#comment1159159_619703 + systemd.services.populate-history = { + script = "echo \"ls -al /nix/store\" >> /home/nixuser/.bash_history"; + wantedBy = [ "multi-user.target" ]; + }; + + virtualisation = { + # following configuration is added only when building VM with build-vm + memorySize = 3072; # Use MiB memory. + diskSize = 4096; # Use MiB memory. + cores = 7; # Simulate 3 cores. + # + podman.enable = true; + + # + useNixStoreImage = true; + writableStore = true; # TODO + }; + security.polkit.enable = true; + + # https://nixos.wiki/wiki/Libvirt + boot.extraModprobeConfig = "options kvm_intel nested=1"; + boot.kernelModules = [ + "kvm-intel" + "vfio-pci" + ]; + + # hardware.opengl.enable = true; + # hardware.opengl.driSupport = true; + + nixpkgs.config.allowUnfree = true; + nix = { + package = pkgs.nix; + # package = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.nix; + extraOptions = "experimental-features = nix-command flakes"; + readOnlyStore = true; + }; + + boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + + # Enable the X11 windowing system. + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + displayManager.startx.enable = true; + logFile = "/var/log/X.0.log"; + desktopManager.xterm.enable = true; + # displayManager.gdm.autoLogin.enable = true; + # displayManager.gdm.autoLogin.user = "nixuser"; + }; + services.spice-vdagentd.enable = true; + + # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 + services.openssh = { + allowSFTP = true; + kbdInteractiveAuthentication = false; + enable = true; + forwardX11 = true; + passwordAuthentication = false; + permitRootLogin = "yes"; + ports = [ 10022 ]; + authorizedKeysFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + + # https://stackoverflow.com/a/71247061 + # https://nixos.wiki/wiki/Firewall + # networking.firewall = { + # enable = true; + # allowedTCPPorts = [ 22 80 443 10022 8000 ]; + # }; + + programs.ssh.forwardX11 = true; + services.qemuGuest.enable = true; + + services.sshd.enable = true; + + programs.dconf.enable = true; + + time.timeZone = "America/Recife"; + system.stateVersion = "22.11"; + + users.users.root = { + password = "root"; + initialPassword = "root"; + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + }) + ]; + }; nixosConfigurations.nixosBuildVMAarch64Linux = let pkgs = import nixpkgs { diff --git a/profile/README.md b/profile/README.md index 114246f..7f6b00f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -703,7 +703,32 @@ build \ "$EXPR_NIX" ``` +#### x86_64-linux + + +```bash +nix \ +build \ +--max-jobs auto \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +``` + +```bash +nix \ +build \ +--max-jobs auto \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +github:PedroRegisPOAR/.github/991bde1c67c86bc382601c01b2cb7dd6754c953e#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +``` + + +#### aarch64-linux ```bash nix \ build \ From 5ef51c7cc275a4298c8870e73dddf40ca39aa04c Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 2 May 2023 01:50:09 -0300 Subject: [PATCH 082/191] WIP --- flake.nix | 4 ++-- profile/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 6ffe78f..49c82cc 100644 --- a/flake.nix +++ b/flake.nix @@ -109,11 +109,11 @@ autoSubUidGidRange = true; openssh.authorizedKeys.keyFiles = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" + "${ ./nixuser-keys.pub }" ]; openssh.authorizedKeys.keys = [ - "${ ./nixuser-keys.pub }" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" ]; }; diff --git a/profile/README.md b/profile/README.md index 7f6b00f..0aefc51 100644 --- a/profile/README.md +++ b/profile/README.md @@ -724,7 +724,7 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/991bde1c67c86bc382601c01b2cb7dd6754c953e#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/d240e5ae0449c9802b0590193c0ed024f6c14ba6#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm ``` From f7d21468df1d0debf89826184869230a8a46299b Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 2 May 2023 10:39:56 -0300 Subject: [PATCH 083/191] WIP --- profile/README.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index 0aefc51..eb8260f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -703,6 +703,7 @@ build \ "$EXPR_NIX" ``` + #### x86_64-linux @@ -724,11 +725,81 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/d240e5ae0449c9802b0590193c0ed024f6c14ba6#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm + +send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +``` + + +```bash +time \ +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +build \ +--keep-failed \ +--max-jobs 0 \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +--print-out-paths \ +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +``` + + +```bash +mkdir -pv ~/sandbox/sandbox && cd $_ + +export HOST_MAPPED_PORT=10022 +export REMOVE_DISK=true +export QEMU_NET_OPTS='hostfwd=tcp::10022-:10022,hostfwd=tcp:127.0.0.1:8000-:8000' +export QEMU_OPTS='-nographic' +export SHARED_DIR="$(pwd)" + +"$REMOVE_DISK" && rm -fv nixos.qcow2 +# nc 1>/dev/null 2>/dev/null || nix profile install nixpkgs#netcat +# nc -v -4 localhost "$HOST_MAPPED_PORT" -w 1 -z && echo 'There is something already using the port:'"$HOST_MAPPED_PORT" + +# sudo lsof -t -i tcp:10022 -s tcp:listen +# sudo lsof -t -i tcp:10022 -s tcp:listen | sudo xargs --no-run-if-empty kill + +cat << 'EOF' >> id_ed25519 +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5JcgAAAIjoIwah6CMG +oQAAAAtzc2gtZWQyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5Jcg +AAAEAbL0Z61S8giktfR53dZ2fztctV/0vML24doU0BMGLRZqyhLx5HU63zJJ5Lx4j+NTC/ +OQZ7Weloc8y+On467klyAAAAAAECAwQF +-----END OPENSSH PRIVATE KEY----- +EOF + +chmod -v 0600 id_ed25519 + + +result/bin/run-nixos-vm < /dev/null & + + +while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p 10022 <<<'nix flake metadata nixpkgs'; do \ + echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done \ +&& ssh-keygen -R '[localhost]:10022'; \ +ssh \ +-i id_ed25519 \ +-X \ +-o StrictHostKeyChecking=no \ +nixuser@localhost \ +-p 10022 +#< Date: Wed, 3 May 2023 21:30:10 -0300 Subject: [PATCH 084/191] Testa VMs --- flake.nix | 204 ++++++++++++++++++++++++++++++++++++++++++++++ profile/README.md | 151 +++++++++++++++++++++++++++++++++- 2 files changed, 351 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 49c82cc..0c5b561 100644 --- a/flake.nix +++ b/flake.nix @@ -221,6 +221,210 @@ ]; }; + nixosConfigurations.nixosBuildVMX86_64LinuxDocker = let + pkgs = import nixpkgs { + system = "x86_64-linux"; + config = { allowUnfree = true; }; + }; + in + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + # system = "aarch64-linux"; + modules = let + nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; + in [ + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" + # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" + + ({ + # https://gist.github.com/andir/88458b13c26a04752854608aacb15c8f#file-configuration-nix-L11-L12 + boot.loader.grub.extraConfig = "serial --unit=0 --speed=115200 \n terminal_output serial console; terminal_input serial console"; + boot.kernelParams = [ + "console=tty0" + "console=ttyS0,115200n8" + # Set sensible kernel parameters + # https://nixos.wiki/wiki/Bootloader + # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT + "boot.shell_on_fail" + "panic=30" + "boot.panic_on_fail" # reboot the machine upon fatal boot issues + # TODO: test it + "intel_iommu=on" + "iommu=pt" + + # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 + # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 + # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 + # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 + # cgroup_no_v1=all + "swapaccount=0" + "systemd.unified_cgroup_hierarchy=0" + "group_enable=memory" + ]; + + boot.tmpOnTmpfs = false; + # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 + boot.tmpOnTmpfsSize = "100%"; + + # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm + users.extraGroups.nixgroup.gid = 999; + + users.users.nixuser = { + isSystemUser = true; + password = "1"; + createHome = true; + home = "/home/nixuser"; + homeMode = "0700"; + description = "The VM tester user"; + group = "nixgroup"; + extraGroups = [ + "docker" + "kvm" + "libvirtd" + "wheel" + ]; + packages = with pkgs; [ + direnv + gitFull + xorg.xclock + file + # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello + btop + # firefox + # vscode + # (python3.buildEnv.override + # { + # extraLibs = with python3Packages; [ scikitimage opencv2 numpy ]; + # } + # ) + ]; + shell = pkgs.bashInteractive; + uid = 1234; + autoSubUidGidRange = true; + + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" + ]; + }; + + systemd.services.adds-change-workdir = { + script = "echo cd /tmp/shared >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.services.creates-if-not-exist = { + script = "echo touch /home/nixuser/.Xauthority >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + # https://unix.stackexchange.com/questions/619671/declaring-a-sym-link-in-a-users-home-directory#comment1159159_619703 + systemd.services.populate-history = { + script = "echo \"ls -al /nix/store\" >> /home/nixuser/.bash_history"; + wantedBy = [ "multi-user.target" ]; + }; + + virtualisation = { + # following configuration is added only when building VM with build-vm + memorySize = 3072; # Use MiB memory. + diskSize = 4096; # Use MiB memory. + cores = 7; # Simulate 3 cores. + # + docker.enable = true; + + # + useNixStoreImage = true; + writableStore = true; # TODO + }; + security.polkit.enable = true; + + environment.etc."containers/registries.conf" = { + mode = "0644"; + text = '' + [registries.search] + registries = ['docker.io', 'localhost'] + ''; + }; + + # https://nixos.wiki/wiki/Libvirt + boot.extraModprobeConfig = "options kvm_intel nested=1"; + boot.kernelModules = [ + "kvm-intel" + "vfio-pci" + ]; + + # hardware.opengl.enable = true; + # hardware.opengl.driSupport = true; + + nixpkgs.config.allowUnfree = true; + nix = { + package = pkgs.nix; + # package = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.nix; + extraOptions = "experimental-features = nix-command flakes"; + readOnlyStore = true; + }; + + boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + + # Enable the X11 windowing system. + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + displayManager.startx.enable = true; + logFile = "/var/log/X.0.log"; + desktopManager.xterm.enable = true; + # displayManager.gdm.autoLogin.enable = true; + # displayManager.gdm.autoLogin.user = "nixuser"; + }; + services.spice-vdagentd.enable = true; + + # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 + services.openssh = { + allowSFTP = true; + kbdInteractiveAuthentication = false; + enable = true; + forwardX11 = true; + passwordAuthentication = false; + permitRootLogin = "yes"; + ports = [ 10022 ]; + authorizedKeysFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + + # https://stackoverflow.com/a/71247061 + # https://nixos.wiki/wiki/Firewall + # networking.firewall = { + # enable = true; + # allowedTCPPorts = [ 22 80 443 10022 8000 ]; + # }; + + programs.ssh.forwardX11 = true; + services.qemuGuest.enable = true; + + services.sshd.enable = true; + + programs.dconf.enable = true; + + time.timeZone = "America/Recife"; + system.stateVersion = "22.11"; + + users.users.root = { + password = "root"; + initialPassword = "root"; + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + }) + ]; + }; + nixosConfigurations.nixosBuildVMAarch64Linux = let pkgs = import nixpkgs { # system = "x86_64-linux"; diff --git a/profile/README.md b/profile/README.md index eb8260f..00255bc 100644 --- a/profile/README.md +++ b/profile/README.md @@ -778,7 +778,23 @@ EOF chmod -v 0600 id_ed25519 -result/bin/run-nixos-vm < /dev/null & +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +build \ +--keep-failed \ +--max-jobs 0 \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +--print-out-paths \ +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm + +nix \ +run \ +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm \ +< /dev/null & while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p 10022 <<<'nix flake metadata nixpkgs'; do \ @@ -790,6 +806,7 @@ ssh \ -o StrictHostKeyChecking=no \ nixuser@localhost \ -p 10022 + #</dev/null 2>/dev/null || nix profile install nixpkgs#netcat +# nc -v -4 localhost "$HOST_MAPPED_PORT" -w 1 -z && echo 'There is something already using the port:'"$HOST_MAPPED_PORT" + +# sudo lsof -t -i tcp:10022 -s tcp:listen +# sudo lsof -t -i tcp:10022 -s tcp:listen | sudo xargs --no-run-if-empty kill + +cat << 'EOF' >> id_ed25519 +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5JcgAAAIjoIwah6CMG +oQAAAAtzc2gtZWQyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5Jcg +AAAEAbL0Z61S8giktfR53dZ2fztctV/0vML24doU0BMGLRZqyhLx5HU63zJJ5Lx4j+NTC/ +OQZ7Weloc8y+On467klyAAAAAAECAwQF +-----END OPENSSH PRIVATE KEY----- +EOF + +chmod -v 0600 id_ed25519 + + +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +build \ +--keep-failed \ +--max-jobs 0 \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +--print-out-paths \ +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm + +nix \ +run \ +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ +< /dev/null & + + +while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p 10022 <<<'nix flake metadata nixpkgs'; do \ + echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done \ +&& ssh-keygen -R '[localhost]:10022'; \ +ssh \ +-i id_ed25519 \ +-X \ +-o StrictHostKeyChecking=no \ +nixuser@localhost \ +-p 10022 + +#< Date: Wed, 3 May 2023 22:16:44 -0300 Subject: [PATCH 085/191] Testa VMs --- flake.nix | 8 +++---- profile/README.md | 59 +++++++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/flake.nix b/flake.nix index 0c5b561..a08d98b 100644 --- a/flake.nix +++ b/flake.nix @@ -399,10 +399,10 @@ # https://stackoverflow.com/a/71247061 # https://nixos.wiki/wiki/Firewall - # networking.firewall = { - # enable = true; - # allowedTCPPorts = [ 22 80 443 10022 8000 ]; - # }; + networking.firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 10022 8000 ]; + }; programs.ssh.forwardX11 = true; services.qemuGuest.enable = true; diff --git a/profile/README.md b/profile/README.md index 00255bc..b2d0a25 100644 --- a/profile/README.md +++ b/profile/README.md @@ -835,10 +835,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -855,7 +855,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -899,11 +899,11 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ +github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ < /dev/null & @@ -924,6 +924,35 @@ nixuser@localhost \ ``` +```bash +export DOCKER_HOST=ssh://nixuser@localhost:10022 + +docker run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' +``` +Refs.: +- https://dev.to/jillesvangurp/docker-over-qemu-on-a-mac-1ajp + + +```bash +ssh -L 8000:localhost:8000 -p 10022 nixuser@localhost +``` + +```bash +nix run nixpkgs#python3 -- -m http.server 8000 +``` + +In the host (client machine): +```bash +test $(curl -s -w '%{http_code}\n' localhost:9000 -o /dev/null) -eq 200 || echo 'Error' +``` + + +```bash +podman --remote --identity id_ed25519 --url ssh://nixuser@localhost:10022 images +``` +Refs.: +- https://stackoverflow.com/a/74634171 + #### aarch64-linux @@ -1018,23 +1047,3 @@ tr '\0' '\n' < /proc/${PID}/cmdline strace -f -T -y -e trace=file ``` - -```bash -export DOCKER_HOST=ssh://nixuser@localhost:10022 - -docker run -p8080:80 nginx - - -ssh -L 8080:localhost:8080 -p 10022 nixuser@localhost -``` -Refs.: -- https://dev.to/jillesvangurp/docker-over-qemu-on-a-mac-1ajp - - - - -```bash -podman --remote --identity id_ed25519 --url ssh://nixuser@localhost:10022 images -``` -Refs.: -- https://stackoverflow.com/a/74634171 From 41681e1916f1c3a1715cc6084e72abf609029794 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 3 May 2023 22:39:50 -0300 Subject: [PATCH 086/191] Testa VMs --- flake.nix | 8 ++++---- profile/README.md | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index a08d98b..0a7c8ec 100644 --- a/flake.nix +++ b/flake.nix @@ -399,10 +399,10 @@ # https://stackoverflow.com/a/71247061 # https://nixos.wiki/wiki/Firewall - networking.firewall = { - enable = true; - allowedTCPPorts = [ 22 80 443 10022 8000 ]; - }; + # networking.firewall = { + # enable = true; + # allowedTCPPorts = [ 22 80 443 10022 8000 ]; + # }; programs.ssh.forwardX11 = true; services.qemuGuest.enable = true; diff --git a/profile/README.md b/profile/README.md index b2d0a25..c20d24c 100644 --- a/profile/README.md +++ b/profile/README.md @@ -835,10 +835,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -855,7 +855,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -899,11 +899,11 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/a3e3cc3ae6654f88a90562ac9694d6d7819512fc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ +github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ < /dev/null & From b7e5192444b0af958ba1fc8772d6c4a101bab92a Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 3 May 2023 22:58:07 -0300 Subject: [PATCH 087/191] Testa VMs volta com networking.firewall --- flake.nix | 8 ++++---- profile/README.md | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/flake.nix b/flake.nix index 0a7c8ec..a08d98b 100644 --- a/flake.nix +++ b/flake.nix @@ -399,10 +399,10 @@ # https://stackoverflow.com/a/71247061 # https://nixos.wiki/wiki/Firewall - # networking.firewall = { - # enable = true; - # allowedTCPPorts = [ 22 80 443 10022 8000 ]; - # }; + networking.firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 10022 8000 ]; + }; programs.ssh.forwardX11 = true; services.qemuGuest.enable = true; diff --git a/profile/README.md b/profile/README.md index c20d24c..14a3c38 100644 --- a/profile/README.md +++ b/profile/README.md @@ -835,10 +835,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -855,7 +855,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -864,7 +864,7 @@ mkdir -pv ~/sandbox/sandbox && cd $_ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true -export QEMU_NET_OPTS='hostfwd=tcp::10022-:10022,hostfwd=tcp:127.0.0.1:8000-:8000' +export QEMU_NET_OPTS='hostfwd=tcp::10022-:10022,hostfwd=tcp::8000-:8000' export QEMU_OPTS='-nographic' export SHARED_DIR="$(pwd)" @@ -888,22 +888,22 @@ EOF chmod -v 0600 id_ed25519 -nix \ ---option eval-cache false \ ---option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ ---option extra-substituters "s3://playing-bucket-nix-cache-test" \ -build \ ---keep-failed \ ---max-jobs 0 \ ---no-link \ ---no-show-trace \ ---print-build-logs \ ---print-out-paths \ -github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +#nix \ +#--option eval-cache false \ +#--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +#--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +#build \ +#--keep-failed \ +#--max-jobs 0 \ +#--no-link \ +#--no-show-trace \ +#--print-build-logs \ +#--print-out-paths \ +#github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/7aaeae4049072d178753779ffd040b7858132614#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ +github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ < /dev/null & @@ -943,7 +943,7 @@ nix run nixpkgs#python3 -- -m http.server 8000 In the host (client machine): ```bash -test $(curl -s -w '%{http_code}\n' localhost:9000 -o /dev/null) -eq 200 || echo 'Error' +test $(curl -s -w '%{http_code}\n' localhost:8000 -o /dev/null) -eq 200 || echo 'Error' ``` From c6ca5765957381ac7fa55b50462f62441ebee989 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 3 May 2023 23:08:40 -0300 Subject: [PATCH 088/191] =?UTF-8?q?Testa=20VMs=20refatora=20ap=C3=B3s=20fi?= =?UTF-8?q?nalmente=20funcionar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/profile/README.md b/profile/README.md index 14a3c38..70bd025 100644 --- a/profile/README.md +++ b/profile/README.md @@ -835,10 +835,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/b7e5192444b0af958ba1fc8772d6c4a101bab92a#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/b7e5192444b0af958ba1fc8772d6c4a101bab92a#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -855,7 +855,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +github:PedroRegisPOAR/.github/b7e5192444b0af958ba1fc8772d6c4a101bab92a#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm ``` @@ -864,16 +864,19 @@ mkdir -pv ~/sandbox/sandbox && cd $_ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true -export QEMU_NET_OPTS='hostfwd=tcp::10022-:10022,hostfwd=tcp::8000-:8000' +export QEMU_NET_OPTS='hostfwd=tcp::'"$HOST_MAPPED_PORT"'-:'"$HOST_MAPPED_PORT"',hostfwd=tcp::8000-:8000' export QEMU_OPTS='-nographic' export SHARED_DIR="$(pwd)" + +pgrep qemu | xargs kill "$REMOVE_DISK" && rm -fv nixos.qcow2 + # nc 1>/dev/null 2>/dev/null || nix profile install nixpkgs#netcat # nc -v -4 localhost "$HOST_MAPPED_PORT" -w 1 -z && echo 'There is something already using the port:'"$HOST_MAPPED_PORT" -# sudo lsof -t -i tcp:10022 -s tcp:listen -# sudo lsof -t -i tcp:10022 -s tcp:listen | sudo xargs --no-run-if-empty kill +# sudo lsof -t -i tcp:"$HOST_MAPPED_PORT" -s tcp:listen +# sudo lsof -t -i tcp:"$HOST_MAPPED_PORT" -s tcp:listen | sudo xargs --no-run-if-empty kill cat << 'EOF' >> id_ed25519 -----BEGIN OPENSSH PRIVATE KEY----- @@ -899,23 +902,24 @@ chmod -v 0600 id_ed25519 #--no-show-trace \ #--print-build-logs \ #--print-out-paths \ -#github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm +#github:PedroRegisPOAR/.github/b7e5192444b0af958ba1fc8772d6c4a101bab92a#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/41681e1916f1c3a1715cc6084e72abf609029794#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ +github:PedroRegisPOAR/.github/b7e5192444b0af958ba1fc8772d6c4a101bab92a#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxDocker.config.system.build.vm \ < /dev/null & -while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p 10022 <<<'nix flake metadata nixpkgs'; do \ +while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'nix flake metadata nixpkgs'; do \ echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done \ -&& ssh-keygen -R '[localhost]:10022'; \ +&& ssh-keygen -R '[localhost]:'"$HOST_MAPPED_PORT"''; \ ssh \ -i id_ed25519 \ -X \ +-o ConnectTimeout=1 \ -o StrictHostKeyChecking=no \ nixuser@localhost \ --p 10022 +-p "$HOST_MAPPED_PORT" #< Date: Wed, 3 May 2023 23:21:50 -0300 Subject: [PATCH 089/191] Testa VMs refatora podman --- profile/README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/profile/README.md b/profile/README.md index 70bd025..a2f2752 100644 --- a/profile/README.md +++ b/profile/README.md @@ -704,9 +704,9 @@ build \ ``` -#### x86_64-linux - +#### x86_64-linux with podman +Podman ```bash nix \ @@ -715,7 +715,7 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` ```bash @@ -725,10 +725,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -745,7 +745,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -754,7 +754,7 @@ mkdir -pv ~/sandbox/sandbox && cd $_ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true -export QEMU_NET_OPTS='hostfwd=tcp::10022-:10022,hostfwd=tcp:127.0.0.1:8000-:8000' +export QEMU_NET_OPTS='hostfwd=tcp::'"$HOST_MAPPED_PORT"'-:'"$HOST_MAPPED_PORT"',hostfwd=tcp::8000-:8000' export QEMU_OPTS='-nographic' export SHARED_DIR="$(pwd)" @@ -762,8 +762,8 @@ export SHARED_DIR="$(pwd)" # nc 1>/dev/null 2>/dev/null || nix profile install nixpkgs#netcat # nc -v -4 localhost "$HOST_MAPPED_PORT" -w 1 -z && echo 'There is something already using the port:'"$HOST_MAPPED_PORT" -# sudo lsof -t -i tcp:10022 -s tcp:listen -# sudo lsof -t -i tcp:10022 -s tcp:listen | sudo xargs --no-run-if-empty kill +# sudo lsof -t -i tcp:"$HOST_MAPPED_PORT" -s tcp:listen +# sudo lsof -t -i tcp:"$HOST_MAPPED_PORT" -s tcp:listen | sudo xargs --no-run-if-empty kill cat << 'EOF' >> id_ed25519 -----BEGIN OPENSSH PRIVATE KEY----- @@ -789,23 +789,23 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64Linux.config.system.build.vm \ +github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & -while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p 10022 <<<'nix flake metadata nixpkgs'; do \ +while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'nix flake metadata nixpkgs'; do \ echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done \ -&& ssh-keygen -R '[localhost]:10022'; \ +&& ssh-keygen -R '[localhost]:'"$HOST_MAPPED_PORT"; \ ssh \ -i id_ed25519 \ -X \ -o StrictHostKeyChecking=no \ nixuser@localhost \ --p 10022 +-p "$HOST_MAPPED_PORT" #< Date: Wed, 3 May 2023 23:25:48 -0300 Subject: [PATCH 090/191] Testa VMs refatora podman --- flake.nix | 12 ++++++------ profile/README.md | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/flake.nix b/flake.nix index a08d98b..e908552 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,7 @@ templates = import ./templates; - nixosConfigurations.nixosBuildVMX86_64Linux = let + nixosConfigurations.nixosBuildVMX86_64LinuxPodman = let pkgs = import nixpkgs { system = "x86_64-linux"; config = { allowUnfree = true; }; @@ -84,7 +84,7 @@ description = "The VM tester user"; group = "nixgroup"; extraGroups = [ - "docker" + "podman" "kvm" "libvirtd" "wheel" @@ -195,10 +195,10 @@ # https://stackoverflow.com/a/71247061 # https://nixos.wiki/wiki/Firewall - # networking.firewall = { - # enable = true; - # allowedTCPPorts = [ 22 80 443 10022 8000 ]; - # }; + networking.firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 10022 8000 ]; + }; programs.ssh.forwardX11 = true; services.qemuGuest.enable = true; diff --git a/profile/README.md b/profile/README.md index a2f2752..12f7c2d 100644 --- a/profile/README.md +++ b/profile/README.md @@ -725,10 +725,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -745,7 +745,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -778,22 +778,22 @@ EOF chmod -v 0600 id_ed25519 -nix \ ---option eval-cache false \ ---option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ ---option extra-substituters "s3://playing-bucket-nix-cache-test" \ -build \ ---keep-failed \ ---max-jobs 0 \ ---no-link \ ---no-show-trace \ ---print-build-logs \ ---print-out-paths \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +#nix \ +#--option eval-cache false \ +#--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +#--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +#build \ +#--keep-failed \ +#--max-jobs 0 \ +#--no-link \ +#--no-show-trace \ +#--print-build-logs \ +#--print-out-paths \ +#github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/5ef51c7cc275a4298c8870e73dddf40ca39aa04c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ +github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & From b39259b3c613c765f28a8653cc325e163035354f Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 4 May 2023 00:18:05 -0300 Subject: [PATCH 091/191] Testa VMs refatora podman --- profile/README.md | 61 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/profile/README.md b/profile/README.md index 12f7c2d..600fa9a 100644 --- a/profile/README.md +++ b/profile/README.md @@ -725,10 +725,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -745,7 +745,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -793,7 +793,7 @@ chmod -v 0600 id_ed25519 nix \ run \ -github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ +github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & @@ -813,6 +813,54 @@ nixuser@localhost \ #"$REMOVE_DISK" && rm -fv nixos.qcow2 id_ed25519 ``` +```bash +export CONTAINER_HOST=ssh://nixuser@localhost:10022/run/user/1234/podman/podman.sock + +podman run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' +``` +Refs.: +- + + +Broken: +```bash +ssh \ +-fnNT \ +-L/tmp/podman.sock:/run/user/1234/podman/podman.sock \ +-i id_ed25519 \ +ssh://nixuser@localhost:10022 \ +-o StreamLocalBindUnlink=yes + +podman run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' +``` +Refs.: +- https://github.com/containers/podman/issues/11397#issuecomment-1321090051 + +```bash +sudo netstat -nptl +``` +Refs.: +- https://serverfault.com/a/1083002 + + +##### podman system connection add + +```bash +export DOCKER_HOST = "ssh://root@podman-romote-host" +podman system connection add --identity ~/.ssh/id_rsa production $DOCKER_HOST +podman run hello-world +``` +Refs.: +- https://stackoverflow.com/a/75533656 +- https://github.com/containers/podman/issues/11668#issuecomment-947983711 + + +```bash +podman --remote --identity id_ed25519 --url ssh://nixuser@localhost:10022 images +``` +Refs.: +- https://stackoverflow.com/a/74634171 + #### x86_64-linux with docker @@ -951,11 +999,6 @@ test $(curl -s -w '%{http_code}\n' localhost:8000 -o /dev/null) -eq 200 || echo ``` -```bash -podman --remote --identity id_ed25519 --url ssh://nixuser@localhost:10022 images -``` -Refs.: -- https://stackoverflow.com/a/74634171 #### aarch64-linux From a9dcf7368426344586427f40f54fe7947d03f018 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 4 May 2023 00:43:14 -0300 Subject: [PATCH 092/191] Adds: podman --- templates/start-config-graphical-full/home.nix | 2 +- templates/start-config/home.nix | 2 +- templates/start-slim-config/home.nix | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 7a5d551..e4cb248 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -209,7 +209,7 @@ openssh # sshfs # TODO: testar - # #podman + podman # runc # skopeo # conmon diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 9cedc23..75c3601 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -253,7 +253,7 @@ openssh # sshfs # TODO: testar - # #podman + podman # runc # skopeo # conmon diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index dbe4426..bf1ef43 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -111,6 +111,8 @@ openssh awscli + podman + ( writeScriptBin "ix" '' #! ${pkgs.runtimeShell} -e From f2ce82df4e792bbde417298a2e93cd1d51644d1b Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 4 May 2023 01:12:07 -0300 Subject: [PATCH 093/191] Refactor: reordering and fix --- profile/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/profile/README.md b/profile/README.md index 600fa9a..dcf91df 100644 --- a/profile/README.md +++ b/profile/README.md @@ -777,6 +777,8 @@ EOF chmod -v 0600 id_ed25519 +# Oh crap, it made me wast many many days +ssh-add id_ed25519 #nix \ #--option eval-cache false \ @@ -822,6 +824,7 @@ Refs.: - + Broken: ```bash ssh \ @@ -831,11 +834,14 @@ ssh \ ssh://nixuser@localhost:10022 \ -o StreamLocalBindUnlink=yes +export CONTAINER_HOST=unix://tmp/podman.sock + podman run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' ``` Refs.: - https://github.com/containers/podman/issues/11397#issuecomment-1321090051 + ```bash sudo netstat -nptl ``` From 25b63fda6625c68d3b6ad206c45d516f0a7efda5 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 4 May 2023 01:39:55 -0300 Subject: [PATCH 094/191] Refactor: fmt --- flake.nix | 933 +++---- .../start-config-graphical-full/flake.nix | 87 +- .../start-config-graphical-full/home.nix | 1931 ++++++++------- templates/start-config/flake.nix | 87 +- templates/start-config/home.nix | 2155 ++++++++--------- templates/start-slim-config/flake.nix | 89 +- templates/start-slim-config/home.nix | 566 ++--- 7 files changed, 2929 insertions(+), 2919 deletions(-) diff --git a/flake.nix b/flake.nix index e908552..9834452 100644 --- a/flake.nix +++ b/flake.nix @@ -5,448 +5,251 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { - self, - nixpkgs, - flake-utils - }: + outputs = + { self + , nixpkgs + , flake-utils + }: flake-utils.lib.eachDefaultSystem (system: - let - name = "imobanco-entrypoint"; + let + name = "imobanco-entrypoint"; - pkgsAllowUnfree = import nixpkgs { - # inherit system; + pkgsAllowUnfree = import nixpkgs { + # inherit system; + system = "x86_64-linux"; + config = { allowUnfree = true; }; + }; + + in + rec { + + templates = import ./templates; + + nixosConfigurations.nixosBuildVMX86_64LinuxPodman = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + config = { allowUnfree = true; }; + }; + in + nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - config = { allowUnfree = true; }; - }; - - in - rec { + # system = "aarch64-linux"; + modules = + let + nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; + in + [ + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" + # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" - templates = import ./templates; + ({ + # https://gist.github.com/andir/88458b13c26a04752854608aacb15c8f#file-configuration-nix-L11-L12 + boot.loader.grub.extraConfig = "serial --unit=0 --speed=115200 \n terminal_output serial console; terminal_input serial console"; + boot.kernelParams = [ + "console=tty0" + "console=ttyS0,115200n8" + # Set sensible kernel parameters + # https://nixos.wiki/wiki/Bootloader + # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT + "boot.shell_on_fail" + "panic=30" + "boot.panic_on_fail" # reboot the machine upon fatal boot issues + # TODO: test it + "intel_iommu=on" + "iommu=pt" - nixosConfigurations.nixosBuildVMX86_64LinuxPodman = let - pkgs = import nixpkgs { - system = "x86_64-linux"; - config = { allowUnfree = true; }; - }; - in - nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - # system = "aarch64-linux"; - modules = let - nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; - in [ - "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" - "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" - # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" - "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" - - ({ - # https://gist.github.com/andir/88458b13c26a04752854608aacb15c8f#file-configuration-nix-L11-L12 - boot.loader.grub.extraConfig = "serial --unit=0 --speed=115200 \n terminal_output serial console; terminal_input serial console"; - boot.kernelParams = [ - "console=tty0" - "console=ttyS0,115200n8" - # Set sensible kernel parameters - # https://nixos.wiki/wiki/Bootloader - # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT - "boot.shell_on_fail" - "panic=30" - "boot.panic_on_fail" # reboot the machine upon fatal boot issues - # TODO: test it - "intel_iommu=on" - "iommu=pt" - - # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 - # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 - # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 - # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 - # cgroup_no_v1=all - "swapaccount=0" - "systemd.unified_cgroup_hierarchy=0" - "group_enable=memory" - ]; + # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 + # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 + # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 + # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 + # cgroup_no_v1=all + "swapaccount=0" + "systemd.unified_cgroup_hierarchy=0" + "group_enable=memory" + ]; - boot.tmpOnTmpfs = false; - # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 - boot.tmpOnTmpfsSize = "100%"; - - # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm - users.extraGroups.nixgroup.gid = 999; - - users.users.nixuser = { - isSystemUser = true; - password = "1"; - createHome = true; - home = "/home/nixuser"; - homeMode = "0700"; - description = "The VM tester user"; - group = "nixgroup"; - extraGroups = [ - "podman" - "kvm" - "libvirtd" - "wheel" - ]; - packages = with pkgs; [ - direnv - gitFull - xorg.xclock - file - # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello - btop - # firefox - # vscode - # (python3.buildEnv.override - # { - # extraLibs = with python3Packages; [ scikitimage opencv2 numpy ]; - # } - # ) - ]; - shell = pkgs.bashInteractive; - uid = 1234; - autoSubUidGidRange = true; + boot.tmpOnTmpfs = false; + # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 + boot.tmpOnTmpfsSize = "100%"; - openssh.authorizedKeys.keyFiles = [ - "${ ./nixuser-keys.pub }" - ]; + # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm + users.extraGroups.nixgroup.gid = 999; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" - ]; - }; - - systemd.services.adds-change-workdir = { - script = "echo cd /tmp/shared >> /home/nixuser/.profile"; - wantedBy = [ "multi-user.target" ]; - }; - - systemd.services.creates-if-not-exist = { - script = "echo touch /home/nixuser/.Xauthority >> /home/nixuser/.profile"; - wantedBy = [ "multi-user.target" ]; - }; - - # https://unix.stackexchange.com/questions/619671/declaring-a-sym-link-in-a-users-home-directory#comment1159159_619703 - systemd.services.populate-history = { - script = "echo \"ls -al /nix/store\" >> /home/nixuser/.bash_history"; - wantedBy = [ "multi-user.target" ]; - }; - - virtualisation = { - # following configuration is added only when building VM with build-vm - memorySize = 3072; # Use MiB memory. - diskSize = 4096; # Use MiB memory. - cores = 7; # Simulate 3 cores. - # - podman.enable = true; - - # - useNixStoreImage = true; - writableStore = true; # TODO - }; - security.polkit.enable = true; - - # https://nixos.wiki/wiki/Libvirt - boot.extraModprobeConfig = "options kvm_intel nested=1"; - boot.kernelModules = [ - "kvm-intel" - "vfio-pci" - ]; + users.users.nixuser = { + isSystemUser = true; + password = "1"; + createHome = true; + home = "/home/nixuser"; + homeMode = "0700"; + description = "The VM tester user"; + group = "nixgroup"; + extraGroups = [ + "podman" + "kvm" + "libvirtd" + "wheel" + ]; + packages = with pkgs; [ + direnv + gitFull + xorg.xclock + file + # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello + btop + # firefox + # vscode + # (python3.buildEnv.override + # { + # extraLibs = with python3Packages; [ scikitimage opencv2 numpy ]; + # } + # ) + ]; + shell = pkgs.bashInteractive; + uid = 1234; + autoSubUidGidRange = true; - # hardware.opengl.enable = true; - # hardware.opengl.driSupport = true; - - nixpkgs.config.allowUnfree = true; - nix = { - package = pkgs.nix; - # package = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.nix; - extraOptions = "experimental-features = nix-command flakes"; - readOnlyStore = true; - }; - - boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; - - # Enable the X11 windowing system. - services.xserver = { - enable = true; - displayManager.gdm.enable = true; - displayManager.startx.enable = true; - logFile = "/var/log/X.0.log"; - desktopManager.xterm.enable = true; - # displayManager.gdm.autoLogin.enable = true; - # displayManager.gdm.autoLogin.user = "nixuser"; - }; - services.spice-vdagentd.enable = true; - - # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 - services.openssh = { - allowSFTP = true; - kbdInteractiveAuthentication = false; - enable = true; - forwardX11 = true; - passwordAuthentication = false; - permitRootLogin = "yes"; - ports = [ 10022 ]; - authorizedKeysFiles = [ - "${ ./nixuser-keys.pub }" - ]; - }; + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; - # https://stackoverflow.com/a/71247061 - # https://nixos.wiki/wiki/Firewall - networking.firewall = { - enable = true; - allowedTCPPorts = [ 22 80 443 10022 8000 ]; - }; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" + ]; + }; - programs.ssh.forwardX11 = true; - services.qemuGuest.enable = true; + systemd.services.adds-change-workdir = { + script = "echo cd /tmp/shared >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; - services.sshd.enable = true; + systemd.services.creates-if-not-exist = { + script = "echo touch /home/nixuser/.Xauthority >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; - programs.dconf.enable = true; + # https://unix.stackexchange.com/questions/619671/declaring-a-sym-link-in-a-users-home-directory#comment1159159_619703 + systemd.services.populate-history = { + script = "echo \"ls -al /nix/store\" >> /home/nixuser/.bash_history"; + wantedBy = [ "multi-user.target" ]; + }; - time.timeZone = "America/Recife"; - system.stateVersion = "22.11"; + virtualisation = { + # following configuration is added only when building VM with build-vm + memorySize = 3072; # Use MiB memory. + diskSize = 4096; # Use MiB memory. + cores = 7; # Simulate 3 cores. + # + podman.enable = true; + + # + useNixStoreImage = true; + writableStore = true; # TODO + }; + security.polkit.enable = true; - users.users.root = { - password = "root"; - initialPassword = "root"; - openssh.authorizedKeys.keyFiles = [ - "${ ./nixuser-keys.pub }" - ]; - }; - }) - ]; - }; - - nixosConfigurations.nixosBuildVMX86_64LinuxDocker = let - pkgs = import nixpkgs { - system = "x86_64-linux"; - config = { allowUnfree = true; }; - }; - in - nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - # system = "aarch64-linux"; - modules = let - nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; - in [ - "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" - "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" - # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" - "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" - - ({ - # https://gist.github.com/andir/88458b13c26a04752854608aacb15c8f#file-configuration-nix-L11-L12 - boot.loader.grub.extraConfig = "serial --unit=0 --speed=115200 \n terminal_output serial console; terminal_input serial console"; - boot.kernelParams = [ - "console=tty0" - "console=ttyS0,115200n8" - # Set sensible kernel parameters - # https://nixos.wiki/wiki/Bootloader - # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT - "boot.shell_on_fail" - "panic=30" - "boot.panic_on_fail" # reboot the machine upon fatal boot issues - # TODO: test it - "intel_iommu=on" - "iommu=pt" - - # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 - # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 - # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 - # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 - # cgroup_no_v1=all - "swapaccount=0" - "systemd.unified_cgroup_hierarchy=0" - "group_enable=memory" - ]; + # https://nixos.wiki/wiki/Libvirt + boot.extraModprobeConfig = "options kvm_intel nested=1"; + boot.kernelModules = [ + "kvm-intel" + "vfio-pci" + ]; - boot.tmpOnTmpfs = false; - # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 - boot.tmpOnTmpfsSize = "100%"; - - # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm - users.extraGroups.nixgroup.gid = 999; - - users.users.nixuser = { - isSystemUser = true; - password = "1"; - createHome = true; - home = "/home/nixuser"; - homeMode = "0700"; - description = "The VM tester user"; - group = "nixgroup"; - extraGroups = [ - "docker" - "kvm" - "libvirtd" - "wheel" - ]; - packages = with pkgs; [ - direnv - gitFull - xorg.xclock - file - # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello - btop - # firefox - # vscode - # (python3.buildEnv.override - # { - # extraLibs = with python3Packages; [ scikitimage opencv2 numpy ]; - # } - # ) - ]; - shell = pkgs.bashInteractive; - uid = 1234; - autoSubUidGidRange = true; + # hardware.opengl.enable = true; + # hardware.opengl.driSupport = true; - openssh.authorizedKeys.keyFiles = [ - "${ ./nixuser-keys.pub }" - ]; + nixpkgs.config.allowUnfree = true; + nix = { + package = pkgs.nix; + # package = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.nix; + extraOptions = "experimental-features = nix-command flakes"; + readOnlyStore = true; + }; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" - ]; - }; - - systemd.services.adds-change-workdir = { - script = "echo cd /tmp/shared >> /home/nixuser/.profile"; - wantedBy = [ "multi-user.target" ]; - }; - - systemd.services.creates-if-not-exist = { - script = "echo touch /home/nixuser/.Xauthority >> /home/nixuser/.profile"; - wantedBy = [ "multi-user.target" ]; - }; - - # https://unix.stackexchange.com/questions/619671/declaring-a-sym-link-in-a-users-home-directory#comment1159159_619703 - systemd.services.populate-history = { - script = "echo \"ls -al /nix/store\" >> /home/nixuser/.bash_history"; - wantedBy = [ "multi-user.target" ]; - }; - - virtualisation = { - # following configuration is added only when building VM with build-vm - memorySize = 3072; # Use MiB memory. - diskSize = 4096; # Use MiB memory. - cores = 7; # Simulate 3 cores. - # - docker.enable = true; - - # - useNixStoreImage = true; - writableStore = true; # TODO - }; - security.polkit.enable = true; - - environment.etc."containers/registries.conf" = { - mode = "0644"; - text = '' - [registries.search] - registries = ['docker.io', 'localhost'] - ''; - }; - - # https://nixos.wiki/wiki/Libvirt - boot.extraModprobeConfig = "options kvm_intel nested=1"; - boot.kernelModules = [ - "kvm-intel" - "vfio-pci" - ]; + boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + + # Enable the X11 windowing system. + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + displayManager.startx.enable = true; + logFile = "/var/log/X.0.log"; + desktopManager.xterm.enable = true; + # displayManager.gdm.autoLogin.enable = true; + # displayManager.gdm.autoLogin.user = "nixuser"; + }; + services.spice-vdagentd.enable = true; + + # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 + services.openssh = { + allowSFTP = true; + kbdInteractiveAuthentication = false; + enable = true; + forwardX11 = true; + passwordAuthentication = false; + permitRootLogin = "yes"; + ports = [ 10022 ]; + authorizedKeysFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; - # hardware.opengl.enable = true; - # hardware.opengl.driSupport = true; - - nixpkgs.config.allowUnfree = true; - nix = { - package = pkgs.nix; - # package = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.nix; - extraOptions = "experimental-features = nix-command flakes"; - readOnlyStore = true; - }; - - boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; - - # Enable the X11 windowing system. - services.xserver = { - enable = true; - displayManager.gdm.enable = true; - displayManager.startx.enable = true; - logFile = "/var/log/X.0.log"; - desktopManager.xterm.enable = true; - # displayManager.gdm.autoLogin.enable = true; - # displayManager.gdm.autoLogin.user = "nixuser"; - }; - services.spice-vdagentd.enable = true; - - # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 - services.openssh = { - allowSFTP = true; - kbdInteractiveAuthentication = false; - enable = true; - forwardX11 = true; - passwordAuthentication = false; - permitRootLogin = "yes"; - ports = [ 10022 ]; - authorizedKeysFiles = [ - "${ ./nixuser-keys.pub }" - ]; - }; + # https://stackoverflow.com/a/71247061 + # https://nixos.wiki/wiki/Firewall + networking.firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 10022 8000 ]; + }; - # https://stackoverflow.com/a/71247061 - # https://nixos.wiki/wiki/Firewall - networking.firewall = { - enable = true; - allowedTCPPorts = [ 22 80 443 10022 8000 ]; - }; + programs.ssh.forwardX11 = true; + services.qemuGuest.enable = true; - programs.ssh.forwardX11 = true; - services.qemuGuest.enable = true; + services.sshd.enable = true; - services.sshd.enable = true; + programs.dconf.enable = true; - programs.dconf.enable = true; + time.timeZone = "America/Recife"; + system.stateVersion = "22.11"; - time.timeZone = "America/Recife"; - system.stateVersion = "22.11"; + users.users.root = { + password = "root"; + initialPassword = "root"; + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + }) + ]; + }; - users.users.root = { - password = "root"; - initialPassword = "root"; - openssh.authorizedKeys.keyFiles = [ - "${ ./nixuser-keys.pub }" - ]; - }; - }) - ]; - }; - - nixosConfigurations.nixosBuildVMAarch64Linux = let - pkgs = import nixpkgs { - # system = "x86_64-linux"; - system = "aarch64-linux"; - config = { allowUnfree = true; }; - }; - in - nixpkgs.lib.nixosSystem - { - system = "aarch64-linux"; - modules = let - nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; - in [ + nixosConfigurations.nixosBuildVMX86_64LinuxDocker = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + config = { allowUnfree = true; }; + }; + in + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + # system = "aarch64-linux"; + modules = + let + nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; + in + [ "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" ({ + # https://gist.github.com/andir/88458b13c26a04752854608aacb15c8f#file-configuration-nix-L11-L12 + boot.loader.grub.extraConfig = "serial --unit=0 --speed=115200 \n terminal_output serial console; terminal_input serial console"; boot.kernelParams = [ "console=tty0" - "console=ttyAMA0,115200n8" + "console=ttyS0,115200n8" # Set sensible kernel parameters # https://nixos.wiki/wiki/Bootloader # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT @@ -476,24 +279,32 @@ users.users.nixuser = { isSystemUser = true; - password = ""; + password = "1"; createHome = true; home = "/home/nixuser"; homeMode = "0700"; description = "The VM tester user"; group = "nixgroup"; extraGroups = [ - "podman" - "kvm" - "libvirtd" - "wheel" + "docker" + "kvm" + "libvirtd" + "wheel" ]; packages = with pkgs; [ - direnv - file - gnumake - which - coreutils + direnv + gitFull + xorg.xclock + file + # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello + btop + # firefox + # vscode + # (python3.buildEnv.override + # { + # extraLibs = with python3Packages; [ scikitimage opencv2 numpy ]; + # } + # ) ]; shell = pkgs.bashInteractive; uid = 1234; @@ -508,11 +319,209 @@ ]; }; + systemd.services.adds-change-workdir = { + script = "echo cd /tmp/shared >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.services.creates-if-not-exist = { + script = "echo touch /home/nixuser/.Xauthority >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + # https://unix.stackexchange.com/questions/619671/declaring-a-sym-link-in-a-users-home-directory#comment1159159_619703 + systemd.services.populate-history = { + script = "echo \"ls -al /nix/store\" >> /home/nixuser/.bash_history"; + wantedBy = [ "multi-user.target" ]; + }; + + virtualisation = { + # following configuration is added only when building VM with build-vm + memorySize = 3072; # Use MiB memory. + diskSize = 4096; # Use MiB memory. + cores = 7; # Simulate 3 cores. + # + docker.enable = true; + + # + useNixStoreImage = true; + writableStore = true; # TODO + }; + security.polkit.enable = true; + + environment.etc."containers/registries.conf" = { + mode = "0644"; + text = '' + [registries.search] + registries = ['docker.io', 'localhost'] + ''; + }; + + # https://nixos.wiki/wiki/Libvirt + boot.extraModprobeConfig = "options kvm_intel nested=1"; + boot.kernelModules = [ + "kvm-intel" + "vfio-pci" + ]; + + # hardware.opengl.enable = true; + # hardware.opengl.driSupport = true; + + nixpkgs.config.allowUnfree = true; + nix = { + package = pkgs.nix; + # package = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.nix; + extraOptions = "experimental-features = nix-command flakes"; + readOnlyStore = true; + }; + + boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + + # Enable the X11 windowing system. + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + displayManager.startx.enable = true; + logFile = "/var/log/X.0.log"; + desktopManager.xterm.enable = true; + # displayManager.gdm.autoLogin.enable = true; + # displayManager.gdm.autoLogin.user = "nixuser"; + }; + services.spice-vdagentd.enable = true; + + # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 + services.openssh = { + allowSFTP = true; + kbdInteractiveAuthentication = false; + enable = true; + forwardX11 = true; + passwordAuthentication = false; + permitRootLogin = "yes"; + ports = [ 10022 ]; + authorizedKeysFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + + # https://stackoverflow.com/a/71247061 + # https://nixos.wiki/wiki/Firewall + networking.firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 10022 8000 ]; + }; + + programs.ssh.forwardX11 = true; + services.qemuGuest.enable = true; + + services.sshd.enable = true; + + programs.dconf.enable = true; + + time.timeZone = "America/Recife"; + system.stateVersion = "22.11"; + + users.users.root = { + password = "root"; + initialPassword = "root"; + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + }) + ]; + }; + + nixosConfigurations.nixosBuildVMAarch64Linux = + let + pkgs = import nixpkgs { + # system = "x86_64-linux"; + system = "aarch64-linux"; + config = { allowUnfree = true; }; + }; + in + nixpkgs.lib.nixosSystem + { + system = "aarch64-linux"; + modules = + let + nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; + in + [ + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" + # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" + + ({ + boot.kernelParams = [ + "console=tty0" + "console=ttyAMA0,115200n8" + # Set sensible kernel parameters + # https://nixos.wiki/wiki/Bootloader + # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT + "boot.shell_on_fail" + "panic=30" + "boot.panic_on_fail" # reboot the machine upon fatal boot issues + # TODO: test it + "intel_iommu=on" + "iommu=pt" + + # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 + # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 + # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 + # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 + # cgroup_no_v1=all + "swapaccount=0" + "systemd.unified_cgroup_hierarchy=0" + "group_enable=memory" + ]; + + boot.tmpOnTmpfs = false; + # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 + boot.tmpOnTmpfsSize = "100%"; + + # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm + users.extraGroups.nixgroup.gid = 999; + + users.users.nixuser = { + isSystemUser = true; + password = ""; + createHome = true; + home = "/home/nixuser"; + homeMode = "0700"; + description = "The VM tester user"; + group = "nixgroup"; + extraGroups = [ + "podman" + "kvm" + "libvirtd" + "wheel" + ]; + packages = with pkgs; [ + direnv + file + gnumake + which + coreutils + ]; + shell = pkgs.bashInteractive; + uid = 1234; + autoSubUidGidRange = true; + + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" + ]; + }; + virtualisation = { # following configuration is added only when building VM with build-vm memorySize = 3072; # Use MiB memory. diskSize = 1024 * 16; # Use MiB memory. - cores = 6; # Simulate 6 cores. + cores = 6; # Simulate 6 cores. # docker.enable = false; @@ -544,49 +553,49 @@ ]; }; - time.timeZone = "America/Recife"; - system.stateVersion = "22.11"; - - users.users.root = { - password = "root"; - initialPassword = "root"; - openssh.authorizedKeys.keyFiles = [ - "${ ./nixuser-keys.pub }" - ]; - }; - }) - ]; - }; - - packages.checkNixFormat = pkgsAllowUnfree.runCommand "check-nix-format" { } '' - ${pkgsAllowUnfree.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} + time.timeZone = "America/Recife"; + system.stateVersion = "22.11"; - # For fix - # find . -type f -iname '*.nix' -exec nixpkgs-fmt {} \; + users.users.root = { + password = "root"; + initialPassword = "root"; + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + }) + ]; + }; + + packages.checkNixFormat = pkgsAllowUnfree.runCommand "check-nix-format" { } '' + ${pkgsAllowUnfree.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.} + + # For fix + # find . -type f -iname '*.nix' -exec nixpkgs-fmt {} \; + + mkdir $out #sucess + ''; + + apps.${name} = flake-utils.lib.mkApp { + inherit name; + drv = packages.${name}; + }; + + devShells.default = pkgsAllowUnfree.mkShell { + buildInputs = with pkgsAllowUnfree; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; - mkdir $out #sucess + shellHook = '' + echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat ''; - - apps.${name} = flake-utils.lib.mkApp { - inherit name; - drv = packages.${name}; - }; - - devShells.default = pkgsAllowUnfree.mkShell { - buildInputs = with pkgsAllowUnfree; [ - bashInteractive - coreutils - curl - gnumake - patchelf - poetry - python3Full - tmate - ]; - - shellHook = '' - echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat - ''; - }; - }); + }; + }); } diff --git a/templates/start-config-graphical-full/flake.nix b/templates/start-config-graphical-full/flake.nix index 782c2bb..f443270 100644 --- a/templates/start-config-graphical-full/flake.nix +++ b/templates/start-config-graphical-full/flake.nix @@ -1,51 +1,52 @@ - { - description = "Home Manager configuration"; +{ + description = "Home Manager configuration"; - inputs = { - # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; - outputs = { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - username = "1M0b4nc0"; - hostname = "fooo"; + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "1M0b4nc0"; + hostname = "fooo"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; - in { - homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; - modules = [ - { - home = { - inherit username; - homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! - stateVersion = "22.11"; - }; - programs.home-manager.enable = true; - } - ./home.nix - ]; + modules = [ + { + home = { + inherit username; + homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; - # TODO: how to: Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; + # TODO: how to: Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ - bashInteractive - coreutils - curl - gnumake - patchelf - poetry - python3Full - tmate - ]; - }; + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; }; - } + }; +} diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index e4cb248..9da4d6c 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -216,48 +216,48 @@ # slirp4netns # shadow - ( - writeScriptBin "ix" '' - #! ${pkgs.runtimeShell} -e - "$@" | "curl" -F 'f:1=<-' ix.io - '' - ) - - ( - writeScriptBin "erw" '' - #! ${pkgs.runtimeShell} -e - echo "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "crw" '' - #! ${pkgs.runtimeShell} -e - cat "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "generate-new-ed25519-key-pair" '' - #! ${pkgs.runtimeShell} -e - - ssh-keygen \ - -t ed25519 \ - -C "$(git config user.email)" \ - -f "$HOME"/.ssh/id_ed25519 \ - -N "" \ - && echo \ - && cat "$HOME"/.ssh/id_ed25519.pub \ - && echo - '' - ) - - ( - writeScriptBin "nfm" '' - #! ${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "$HOME"/.ssh/id_ed25519 \ + -N "" \ + && echo \ + && cat "$HOME"/.ssh/id_ed25519.pub \ + && echo + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) ( writeScriptBin "hms" '' @@ -274,28 +274,28 @@ '' ) - ( - writeScriptBin "build-pulling-all-from-cache" '' - #! ${pkgs.runtimeShell} -e - - set -x - - export NIXPKGS_ALLOW_UNFREE=1 - - nix \ - --option eval-cache false \ - --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - build \ - --impure \ - --keep-failed \ - --max-jobs 0 \ - --no-link \ - --print-build-logs \ - --print-out-paths \ - ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage - '' - ) + ( + writeScriptBin "build-pulling-all-from-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + export NIXPKGS_ALLOW_UNFREE=1 + + nix \ + --option eval-cache false \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ + build \ + --impure \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + '' + ) ( writeScriptBin "gphms-cache" '' @@ -535,910 +535,909 @@ # https://gist.github.com/s-a-c/0e44dc7766922308924812d4c019b109 # https://gist.github.com/search?q=So+either+put+%22Important+Documents%22+before+%22Documents%22+or+use+the+substituted+version%3A%3B&ref=searchresults programs.starship = { - enable = true; - enableZshIntegration = true; - settings = { - # "$schema" = "https://starship.rs/config-schema.json"; - add_newline = true; - command_timeout = 500; - continuation_prompt = "[∙](bright-black) "; - # format = "[](0x9A348E)$username$hostname$localip$shlvl$singularity$kubernetes[](fg:0x9A348E bg:0xDA627D)$directory$vcsh[](fg:0xDA627D bg:0xFCA17D)$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch[](fg:0x86BBD8 bg:0x06969A)$docker_context$package$buf[](fg:0xFCA17D bg:0x86BBD8)$c$cmake$cobol$container$daml$dart$deno$dotnet$elixir$elm$erlang$golang$haskell$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$nix_shell$conda$spack$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery[](fg:0x06969A bg:0x33658A)$time$status$shell$character"; - right_format = ""; - scan_timeout = 30; - aws = { - format = "[$symbol($profile )(($region) )([$duration] )]($style)"; - symbol = "🅰 "; - style = "bold yellow"; - disabled = false; - expiration_symbol = "X"; - force_display = false; - }; - aws.region_aliases = {}; - aws.profile_aliases = {}; - azure = { - format = "[$symbol($subscription)([$duration])]($style) "; - symbol = "ﴃ "; - style = "blue bold"; - disabled = true; - }; - battery = { - format = "[$symbol$percentage]($style) "; - charging_symbol = " "; - discharging_symbol = " "; - empty_symbol = " "; - full_symbol = " "; - unknown_symbol = " "; - disabled = false; - display = [ - { - style = "red bold"; - threshold = 10; - } - ]; - }; - buf = { - format = "[$symbol ($version)]($style)"; - version_format = "v$raw"; - symbol = ""; - style = "bold blue"; - disabled = false; - detect_extensions = []; - detect_files = [ - "buf.yaml" - "buf.gen.yaml" - "buf.work.yaml" - ]; - detect_folders = []; - }; - c = { - format = "[$symbol($version(-$name) )]($style)"; - version_format = "v$raw"; - style = "fg:149 bold bg:0x86BBD8"; - symbol = " "; - disabled = false; - detect_extensions = [ - "c" - "h" - ]; - detect_files = []; - detect_folders = []; -# commands = [ -# [ -# "cc" -# "--version" -# ] -# [ -# "gcc" -# "--version" -# ] -# [ -# "clang" -# "--version" -# ] -# ]; - }; - character = { - format = "$symbol "; - vicmd_symbol = "[❮](bold green)"; - disabled = false; - success_symbol = "[➜](bold green) "; - error_symbol = "[✗](bold red) "; - }; - cmake = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "△ "; - style = "bold blue"; - disabled = false; - detect_extensions = []; - detect_files = [ - "CMakeLists.txt" - "CMakeCache.txt" - ]; - detect_folders = []; - }; - cmd_duration = { - min_time = 2000; - format = "⏱ [$duration]($style) "; - style = "yellow bold"; - show_milliseconds = false; - disabled = false; - show_notifications = false; - min_time_to_notify = 45000; - }; - cobol = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "⚙️ "; - style = "bold blue"; - disabled = false; - detect_extensions = [ - "cbl" - "cob" - "CBL" - "COB" - ]; - detect_files = []; - detect_folders = []; - }; - conda = { - truncation_length = 1; - format = "[$symbol$environment]($style) "; - symbol = " "; - style = "green bold"; - ignore_base = true; - disabled = false; - }; - container = { - format = "[$symbol [$name]]($style) "; - symbol = "⬢"; - style = "red bold dimmed"; - disabled = false; - }; - crystal = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🔮 "; - style = "bold red"; - disabled = false; - detect_extensions = ["cr"]; - detect_files = ["shard.yml"]; - detect_folders = []; - }; - dart = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🎯 "; - style = "bold blue"; - disabled = false; - detect_extensions = ["dart"]; - detect_files = [ - "pubspec.yaml" - "pubspec.yml" - "pubspec.lock" - ]; - detect_folders = [".dart_tool"]; - }; - deno = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🦕 "; - style = "green bold"; - disabled = false; - detect_extensions = []; - detect_files = [ - "deno.json" - "deno.jsonc" - "mod.ts" - "deps.ts" - "mod.js" - "deps.js" - ]; - detect_folders = []; - }; - directory = { - disabled = false; - fish_style_pwd_dir_length = 0; - format = "[$path]($style)[$read_only]($read_only_style) "; - home_symbol = "~"; - read_only = " "; - read_only_style = "red"; - repo_root_format = "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; - style = "cyan bold bg:0xDA627D"; - truncate_to_repo = true; - truncation_length = 3; - truncation_symbol = "…/"; - use_logical_path = true; - use_os_path_sep = true; - }; - directory.substitutions = { - # Here is how you can shorten some long paths by text replacement; - # similar to mapped_locations in Oh My Posh:; - "Documents" = " "; - "Downloads" = " "; - "Music" = " "; - "Pictures" = " "; - # Keep in mind that the order matters. For example:; - # "Important Documents" = "  "; - # will not be replaced, because "Documents" was already substituted before.; - # So either put "Important Documents" before "Documents" or use the substituted version:; - # "Important  " = "  "; - "Important " = " "; - }; - docker_context = { - format = "[$symbol$context]($style) "; - style = "blue bold bg:0x06969A"; - symbol = " "; - only_with_files = true; - disabled = false; - detect_extensions = []; - detect_files = [ - "docker-compose.yml" - "docker-compose.yaml" - "Dockerfile" - ]; - detect_folders = []; - }; - dotnet = { - format = "[$symbol($version )(🎯 $tfm )]($style)"; - version_format = "v$raw"; - symbol = "🥅 "; - style = "blue bold"; - heuristic = true; - disabled = false; - detect_extensions = [ - "csproj" - "fsproj" - "xproj" - ]; - detect_files = [ - "global.json" - "project.json" - "Directory.Build.props" - "Directory.Build.targets" - "Packages.props" - ]; - detect_folders = []; - }; - elixir = { - format = "[$symbol($version (OTP $otp_version) )]($style)"; - version_format = "v$raw"; - style = "bold purple bg:0x86BBD8"; - symbol = " "; - disabled = false; - detect_extensions = []; - detect_files = ["mix.exs"]; - detect_folders = []; - }; - elm = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - style = "cyan bold bg:0x86BBD8"; - symbol = " "; - disabled = false; - detect_extensions = ["elm"]; - detect_files = [ - "elm.json" - "elm-package.json" - ".elm-version" - ]; - detect_folders = ["elm-stuff"]; - }; - env_var = {}; - env_var.SHELL = { - format = "[$symbol($env_value )]($style)"; - style = "grey bold italic dimmed"; - symbol = "e:"; - disabled = true; - variable = "SHELL"; - default = "unknown shell"; - }; - env_var.USER = { - format = "[$symbol($env_value )]($style)"; - style = "grey bold italic dimmed"; - symbol = "e:"; - disabled = true; - default = "unknown user"; - }; - erlang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = " "; - style = "bold red"; - disabled = false; - detect_extensions = []; - detect_files = [ - "rebar.config" - "erlang.mk" - ]; - detect_folders = []; - }; - fill = { - style = "bold black"; - symbol = "."; - disabled = false; - }; - gcloud = { - format = "[$symbol$account(@$domain)(($region))(($project))]($style) "; - symbol = "☁️ "; - style = "bold blue"; - disabled = false; - }; - gcloud.project_aliases = {}; - gcloud.region_aliases = {}; - git_branch = { - format = "[$symbol$branch(:$remote_branch)]($style) "; - symbol = " "; - style = "bold purple bg:0xFCA17D"; - truncation_length = 9223372036854775807; - truncation_symbol = "…"; - only_attached = false; - always_show_remote = false; - ignore_branches = []; - disabled = false; - }; - git_commit = { - commit_hash_length = 7; - format = "[($hash$tag)]($style) "; - style = "green bold"; - only_detached = true; - disabled = false; - tag_symbol = " 🏷 "; - tag_disabled = true; - }; - git_metrics = { - added_style = "bold green"; - deleted_style = "bold red"; - only_nonzero_diffs = true; - format = "([+$added]($added_style) )([-$deleted]($deleted_style) )"; - disabled = false; - }; - git_state = { - am = "AM"; - am_or_rebase = "AM/REBASE"; - bisect = "BISECTING"; - cherry_pick = "🍒PICKING(bold red)"; - disabled = false; - format = "([$state( $progress_current/$progress_total)]($style)) "; - merge = "MERGING"; - rebase = "REBASING"; - revert = "REVERTING"; - style = "bold yellow"; - }; - git_status = { - ahead = "🏎💨$count"; - behind = "😰$count"; - conflicted = "🏳"; - deleted = "🗑"; - disabled = false; - diverged = "😵"; - # format = "([[$all_status$ahead_behind]]($style) )"; - ignore_submodules = false; - modified = "📝"; - renamed = "👅"; - staged = "[++($count)](green)"; - stashed = "📦"; - style = "red bold bg:0xFCA17D"; - untracked = "🤷"; - up_to_date = "✓"; - }; - golang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = " "; - style = "bold cyan bg:0x86BBD8"; - disabled = false; - detect_extensions = ["go"]; - detect_files = [ - "go.mod" - "go.sum" - "glide.yaml" - "Gopkg.yml" - "Gopkg.lock" - ".go-version" - ]; - detect_folders = ["Godeps"]; - }; - haskell = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "λ "; - style = "bold purple bg:0x86BBD8"; - disabled = false; - detect_extensions = [ - "hs" - "cabal" - "hs-boot" - ]; - detect_files = [ - "stack.yaml" - "cabal.project" - ]; - detect_folders = []; - }; - helm = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "⎈ "; - style = "bold white"; - disabled = false; - detect_extensions = []; - detect_files = [ - "helmfile.yaml" - "Chart.yaml" - ]; - detect_folders = []; - }; - hg_branch = { - symbol = " "; - style = "bold purple"; - format = "on [$symbol$branch]($style) "; - truncation_length = 9223372036854775807; - truncation_symbol = "…"; - disabled = true; - }; - hostname = { - disabled = false; - format = "[$ssh_symbol](blue dimmed bold)[$hostname]($style) "; - ssh_only = false; - style = "green dimmed bold"; - trim_at = "."; - }; - java = { - disabled = false; - format = "[$symbol($version )]($style)"; - style = "red dimmed bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - detect_extensions = [ - "java" - "class" - "jar" - "gradle" - "clj" - "cljc" - ]; - detect_files = [ - "pom.xml" - "build.gradle.kts" - "build.sbt" - ".java-version" - "deps.edn" - "project.clj" - "build.boot" - ]; - detect_folders = []; - }; - jobs = { - threshold = 1; - symbol_threshold = 0; - number_threshold = 2; - format = "[$symbol$number]($style) "; - symbol = "✦"; - style = "bold blue"; - disabled = false; - }; - julia = { - disabled = false; - format = "[$symbol($version )]($style)"; - style = "bold purple bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - detect_extensions = ["jl"]; - detect_files = [ - "Project.toml" - "Manifest.toml" - ]; - detect_folders = []; - }; - kotlin = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🅺 "; - style = "bold blue"; - kotlin_binary = "kotlin"; - disabled = false; - detect_extensions = [ - "kt" - "kts" - ]; - detect_files = []; - detect_folders = []; - }; - kubernetes = { - disabled = false; - format = "[$symbol$context( ($namespace))]($style) in "; - style = "cyan bold"; - symbol = "⛵ "; - }; - kubernetes.context_aliases = {}; - line_break = { - disabled = false; - }; - localip = { - disabled = false; - format = "[@$localipv4]($style) "; - ssh_only = false; - style = "yellow bold"; - }; - lua = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🌙 "; - style = "bold blue"; - lua_binary = "lua"; - disabled = false; - detect_extensions = ["lua"]; - detect_files = [".lua-version"]; - detect_folders = ["lua"]; - }; - memory_usage = { - disabled = false; - format = "$symbol[$ram( | $swap)]($style) "; - style = "white bold dimmed"; - symbol = " "; - # threshold = 75; - threshold = -1; - }; - nim = { - format = "[$symbol($version )]($style)"; - style = "yellow bold bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - disabled = false; - detect_extensions = [ - "nim" - "nims" - "nimble" - ]; - detect_files = ["nim.cfg"]; - detect_folders = []; - }; - nix_shell = { - format = "[$symbol$state( ($name))]($style) "; - disabled = false; - impure_msg = "[impure](bold red)"; - pure_msg = "[pure](bold green)"; - style = "bold blue"; - symbol = " "; - }; - nodejs = { - format = "[$symbol($version )]($style)"; - not_capable_style = "bold red"; - style = "bold green bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - disabled = false; - detect_extensions = [ - "js" - "mjs" - "cjs" - "ts" - "mts" - "cts" - ]; - detect_files = [ - "package.json" - ".node-version" - ".nvmrc" - ]; - detect_folders = ["node_modules"]; - }; - ocaml = { - format = "[$symbol($version )(($switch_indicator$switch_name) )]($style)"; - global_switch_indicator = ""; - local_switch_indicator = "*"; - style = "bold yellow"; - symbol = "🐫 "; - version_format = "v$raw"; - disabled = false; - detect_extensions = [ - "opam" - "ml" - "mli" - "re" - "rei" - ]; - detect_files = [ - "dune" - "dune-project" - "jbuild" - "jbuild-ignore" - ".merlin" - ]; - detect_folders = [ - "_opam" - "esy.lock" - ]; - }; - openstack = { - format = "[$symbol$cloud(($project))]($style) "; - symbol = "☁️ "; - style = "bold yellow"; - disabled = false; - }; - package = { - format = "[$symbol$version]($style) "; - symbol = "📦 "; - style = "208 bold"; - display_private = false; - disabled = false; - version_format = "v$raw"; - }; - perl = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🐪 "; - style = "149 bold"; - disabled = false; - detect_extensions = [ - "pl" - "pm" - "pod" - ]; - detect_files = [ - "Makefile.PL" - "Build.PL" - "cpanfile" - "cpanfile.snapshot" - "META.json" - "META.yml" - ".perl-version" - ]; - detect_folders = []; - }; - php = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🐘 "; - style = "147 bold"; - disabled = false; - detect_extensions = ["php"]; - detect_files = [ - "composer.json" - ".php-version" - ]; - detect_folders = []; - }; - pulumi = { - format = "[$symbol($username@)$stack]($style) "; - version_format = "v$raw"; - symbol = " "; - style = "bold 5"; - disabled = false; - }; - purescript = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "<=> "; - style = "bold white"; - disabled = false; - detect_extensions = ["purs"]; - detect_files = ["spago.dhall"]; - detect_folders = []; - }; - python = { - format = "[$symbol$pyenv_prefix($version )(($virtualenv) )]($style)"; - python_binary = [ - "python" - "python3" - "python2" - ]; - pyenv_prefix = "pyenv "; - pyenv_version_name = true; - style = "yellow bold"; - symbol = "🐍 "; - version_format = "v$raw"; - disabled = false; - detect_extensions = ["py"]; - detect_files = [ - "requirements.txt" - ".python-version" - "pyproject.toml" - "Pipfile" - "tox.ini" - "setup.py" - "__init__.py" - ]; - detect_folders = []; - }; - red = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🔺 "; - style = "red bold"; - disabled = false; - detect_extensions = [ - "red" - "reds" - ]; - detect_files = []; - detect_folders = []; - }; - rlang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - style = "blue bold"; - symbol = "📐 "; - disabled = false; - detect_extensions = [ - "R" - "Rd" - "Rmd" - "Rproj" - "Rsx" - ]; - detect_files = [".Rprofile"]; - detect_folders = [".Rproj.user"]; - }; - ruby = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "💎 "; - style = "bold red"; - disabled = false; - detect_extensions = ["rb"]; - detect_files = [ - "Gemfile" - ".ruby-version" - ]; - detect_folders = []; - detect_variables = [ - "RUBY_VERSION" - "RBENV_VERSION" - ]; - }; - rust = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🦀 "; - style = "bold red bg:0x86BBD8"; - disabled = false; - detect_extensions = ["rs"]; - detect_files = ["Cargo.toml"]; - detect_folders = []; - }; - scala = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - disabled = false; - style = "red bold"; - symbol = "🆂 "; - detect_extensions = [ - "sbt" - "scala" - ]; - detect_files = [ - ".scalaenv" - ".sbtenv" - "build.sbt" - ]; - detect_folders = [".metals"]; - }; - shell = { - format = "[$indicator]($style) "; - bash_indicator = "bsh"; - cmd_indicator = "cmd"; - elvish_indicator = "esh"; - fish_indicator = ""; - ion_indicator = "ion"; - nu_indicator = "nu"; - powershell_indicator = "_"; - style = "white bold"; - tcsh_indicator = "tsh"; - unknown_indicator = "mystery shell"; - xonsh_indicator = "xsh"; - zsh_indicator = "zsh"; - disabled = false; - }; - shlvl = { - threshold = 2; - format = "[$symbol$shlvl]($style) "; - symbol = "↕️ "; - repeat = false; - style = "bold yellow"; - disabled = true; - }; - singularity = { - format = "[$symbol[$env]]($style) "; - style = "blue bold dimmed"; - symbol = "📦 "; - disabled = false; - }; - spack = { - truncation_length = 1; - format = "[$symbol$environment]($style) "; - symbol = "🅢 "; - style = "blue bold"; - disabled = false; - }; - status = { - format = "[$symbol$status]($style) "; - map_symbol = true; - not_executable_symbol = "🚫"; - not_found_symbol = "🔍"; - pipestatus = false; - pipestatus_format = "[$pipestatus] => [$symbol$common_meaning$signal_name$maybe_int]($style)"; - pipestatus_separator = "|"; - recognize_signal_code = true; - signal_symbol = "⚡"; - style = "bold red bg:blue"; - success_symbol = "🟢 SUCCESS"; - symbol = "🔴 "; - disabled = true; - }; - sudo = { - format = "[as $symbol]($style)"; - symbol = "🧙 "; - style = "bold blue"; - allow_windows = false; - disabled = true; - }; - swift = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🐦 "; - style = "bold 202"; - disabled = false; - detect_extensions = ["swift"]; - detect_files = ["Package.swift"]; - detect_folders = []; - }; - terraform = { - format = "[$symbol$workspace]($style) "; - version_format = "v$raw"; - symbol = "💠 "; - style = "bold 105"; - disabled = false; - detect_extensions = [ - "tf" - "tfplan" - "tfstate" - ]; - detect_files = []; - detect_folders = [".terraform"]; - }; - time = { - format = "[$symbol $time]($style) "; - style = "bold yellow bg:0x33658A"; - use_12hr = false; - disabled = false; - utc_time_offset = "local"; - # time_format = "%R"; # Hour:Minute Format; - time_format = "%T"; # Hour:Minute:Seconds Format; - time_range = "-"; - }; - username = { - format = "[$user]($style) "; - show_always = true; - style_root = "red bold bg:0x9A348E"; - style_user = "yellow bold bg:0x9A348E"; - disabled = false; - }; - vagrant = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "⍱ "; - style = "cyan bold"; - disabled = false; - detect_extensions = []; - detect_files = ["Vagrantfile"]; - detect_folders = []; - }; - vcsh = { - symbol = ""; - style = "bold yellow"; - format = "[$symbol$repo]($style) "; - disabled = false; - }; - vlang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "V "; - style = "blue bold"; - disabled = false; - detect_extensions = ["v"]; - detect_files = [ - "v.mod" - "vpkg.json" - ".vpkg-lock.json" - ]; - detect_folders = []; - }; - zig = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "↯ "; - style = "bold yellow"; - disabled = false; - detect_extensions = ["zig"]; - detect_files = []; - detect_folders = []; - }; - custom = { - }; + enable = true; + enableZshIntegration = true; + settings = { + # "$schema" = "https://starship.rs/config-schema.json"; + add_newline = true; + command_timeout = 500; + continuation_prompt = "[∙](bright-black) "; + # format = "[](0x9A348E)$username$hostname$localip$shlvl$singularity$kubernetes[](fg:0x9A348E bg:0xDA627D)$directory$vcsh[](fg:0xDA627D bg:0xFCA17D)$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch[](fg:0x86BBD8 bg:0x06969A)$docker_context$package$buf[](fg:0xFCA17D bg:0x86BBD8)$c$cmake$cobol$container$daml$dart$deno$dotnet$elixir$elm$erlang$golang$haskell$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$nix_shell$conda$spack$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery[](fg:0x06969A bg:0x33658A)$time$status$shell$character"; + right_format = ""; + scan_timeout = 30; + aws = { + format = "[$symbol($profile )(($region) )([$duration] )]($style)"; + symbol = "🅰 "; + style = "bold yellow"; + disabled = false; + expiration_symbol = "X"; + force_display = false; + }; + aws.region_aliases = { }; + aws.profile_aliases = { }; + azure = { + format = "[$symbol($subscription)([$duration])]($style) "; + symbol = "ﴃ "; + style = "blue bold"; + disabled = true; + }; + battery = { + format = "[$symbol$percentage]($style) "; + charging_symbol = " "; + discharging_symbol = " "; + empty_symbol = " "; + full_symbol = " "; + unknown_symbol = " "; + disabled = false; + display = [ + { + style = "red bold"; + threshold = 10; + } + ]; + }; + buf = { + format = "[$symbol ($version)]($style)"; + version_format = "v$raw"; + symbol = ""; + style = "bold blue"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "buf.yaml" + "buf.gen.yaml" + "buf.work.yaml" + ]; + detect_folders = [ ]; + }; + c = { + format = "[$symbol($version(-$name) )]($style)"; + version_format = "v$raw"; + style = "fg:149 bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ + "c" + "h" + ]; + detect_files = [ ]; + detect_folders = [ ]; + # commands = [ + # [ + # "cc" + # "--version" + # ] + # [ + # "gcc" + # "--version" + # ] + # [ + # "clang" + # "--version" + # ] + # ]; + }; + character = { + format = "$symbol "; + vicmd_symbol = "[❮](bold green)"; + disabled = false; + success_symbol = "[➜](bold green) "; + error_symbol = "[✗](bold red) "; + }; + cmake = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "△ "; + style = "bold blue"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "CMakeLists.txt" + "CMakeCache.txt" + ]; + detect_folders = [ ]; + }; + cmd_duration = { + min_time = 2000; + format = "⏱ [$duration]($style) "; + style = "yellow bold"; + show_milliseconds = false; + disabled = false; + show_notifications = false; + min_time_to_notify = 45000; + }; + cobol = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⚙️ "; + style = "bold blue"; + disabled = false; + detect_extensions = [ + "cbl" + "cob" + "CBL" + "COB" + ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + conda = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = " "; + style = "green bold"; + ignore_base = true; + disabled = false; + }; + container = { + format = "[$symbol [$name]]($style) "; + symbol = "⬢"; + style = "red bold dimmed"; + disabled = false; + }; + crystal = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔮 "; + style = "bold red"; + disabled = false; + detect_extensions = [ "cr" ]; + detect_files = [ "shard.yml" ]; + detect_folders = [ ]; + }; + dart = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🎯 "; + style = "bold blue"; + disabled = false; + detect_extensions = [ "dart" ]; + detect_files = [ + "pubspec.yaml" + "pubspec.yml" + "pubspec.lock" + ]; + detect_folders = [ ".dart_tool" ]; + }; + deno = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦕 "; + style = "green bold"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "deno.json" + "deno.jsonc" + "mod.ts" + "deps.ts" + "mod.js" + "deps.js" + ]; + detect_folders = [ ]; + }; + directory = { + disabled = false; + fish_style_pwd_dir_length = 0; + format = "[$path]($style)[$read_only]($read_only_style) "; + home_symbol = "~"; + read_only = " "; + read_only_style = "red"; + repo_root_format = "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; + style = "cyan bold bg:0xDA627D"; + truncate_to_repo = true; + truncation_length = 3; + truncation_symbol = "…/"; + use_logical_path = true; + use_os_path_sep = true; + }; + directory.substitutions = { + # Here is how you can shorten some long paths by text replacement; + # similar to mapped_locations in Oh My Posh:; + "Documents" = " "; + "Downloads" = " "; + "Music" = " "; + "Pictures" = " "; + # Keep in mind that the order matters. For example:; + # "Important Documents" = "  "; + # will not be replaced, because "Documents" was already substituted before.; + # So either put "Important Documents" before "Documents" or use the substituted version:; + # "Important  " = "  "; + "Important " = " "; + }; + docker_context = { + format = "[$symbol$context]($style) "; + style = "blue bold bg:0x06969A"; + symbol = " "; + only_with_files = true; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "docker-compose.yml" + "docker-compose.yaml" + "Dockerfile" + ]; + detect_folders = [ ]; + }; + dotnet = { + format = "[$symbol($version )(🎯 $tfm )]($style)"; + version_format = "v$raw"; + symbol = "🥅 "; + style = "blue bold"; + heuristic = true; + disabled = false; + detect_extensions = [ + "csproj" + "fsproj" + "xproj" + ]; + detect_files = [ + "global.json" + "project.json" + "Directory.Build.props" + "Directory.Build.targets" + "Packages.props" + ]; + detect_folders = [ ]; + }; + elixir = { + format = "[$symbol($version (OTP $otp_version) )]($style)"; + version_format = "v$raw"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ ]; + detect_files = [ "mix.exs" ]; + detect_folders = [ ]; + }; + elm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "cyan bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ "elm" ]; + detect_files = [ + "elm.json" + "elm-package.json" + ".elm-version" + ]; + detect_folders = [ "elm-stuff" ]; + }; + env_var = { }; + env_var.SHELL = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + variable = "SHELL"; + default = "unknown shell"; }; + env_var.USER = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + default = "unknown user"; + }; + erlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold red"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "rebar.config" + "erlang.mk" + ]; + detect_folders = [ ]; + }; + fill = { + style = "bold black"; + symbol = "."; + disabled = false; + }; + gcloud = { + format = "[$symbol$account(@$domain)(($region))(($project))]($style) "; + symbol = "☁️ "; + style = "bold blue"; + disabled = false; + }; + gcloud.project_aliases = { }; + gcloud.region_aliases = { }; + git_branch = { + format = "[$symbol$branch(:$remote_branch)]($style) "; + symbol = " "; + style = "bold purple bg:0xFCA17D"; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + only_attached = false; + always_show_remote = false; + ignore_branches = [ ]; + disabled = false; + }; + git_commit = { + commit_hash_length = 7; + format = "[($hash$tag)]($style) "; + style = "green bold"; + only_detached = true; + disabled = false; + tag_symbol = " 🏷 "; + tag_disabled = true; + }; + git_metrics = { + added_style = "bold green"; + deleted_style = "bold red"; + only_nonzero_diffs = true; + format = "([+$added]($added_style) )([-$deleted]($deleted_style) )"; + disabled = false; + }; + git_state = { + am = "AM"; + am_or_rebase = "AM/REBASE"; + bisect = "BISECTING"; + cherry_pick = "🍒PICKING(bold red)"; + disabled = false; + format = "([$state( $progress_current/$progress_total)]($style)) "; + merge = "MERGING"; + rebase = "REBASING"; + revert = "REVERTING"; + style = "bold yellow"; + }; + git_status = { + ahead = "🏎💨$count"; + behind = "😰$count"; + conflicted = "🏳"; + deleted = "🗑"; + disabled = false; + diverged = "😵"; + # format = "([[$all_status$ahead_behind]]($style) )"; + ignore_submodules = false; + modified = "📝"; + renamed = "👅"; + staged = "[++($count)](green)"; + stashed = "📦"; + style = "red bold bg:0xFCA17D"; + untracked = "🤷"; + up_to_date = "✓"; + }; + golang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold cyan bg:0x86BBD8"; + disabled = false; + detect_extensions = [ "go" ]; + detect_files = [ + "go.mod" + "go.sum" + "glide.yaml" + "Gopkg.yml" + "Gopkg.lock" + ".go-version" + ]; + detect_folders = [ "Godeps" ]; + }; + haskell = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "λ "; + style = "bold purple bg:0x86BBD8"; + disabled = false; + detect_extensions = [ + "hs" + "cabal" + "hs-boot" + ]; + detect_files = [ + "stack.yaml" + "cabal.project" + ]; + detect_folders = [ ]; + }; + helm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⎈ "; + style = "bold white"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "helmfile.yaml" + "Chart.yaml" + ]; + detect_folders = [ ]; + }; + hg_branch = { + symbol = " "; + style = "bold purple"; + format = "on [$symbol$branch]($style) "; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + disabled = true; + }; + hostname = { + disabled = false; + format = "[$ssh_symbol](blue dimmed bold)[$hostname]($style) "; + ssh_only = false; + style = "green dimmed bold"; + trim_at = "."; + }; + java = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "red dimmed bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = [ + "java" + "class" + "jar" + "gradle" + "clj" + "cljc" + ]; + detect_files = [ + "pom.xml" + "build.gradle.kts" + "build.sbt" + ".java-version" + "deps.edn" + "project.clj" + "build.boot" + ]; + detect_folders = [ ]; + }; + jobs = { + threshold = 1; + symbol_threshold = 0; + number_threshold = 2; + format = "[$symbol$number]($style) "; + symbol = "✦"; + style = "bold blue"; + disabled = false; + }; + julia = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = [ "jl" ]; + detect_files = [ + "Project.toml" + "Manifest.toml" + ]; + detect_folders = [ ]; + }; + kotlin = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🅺 "; + style = "bold blue"; + kotlin_binary = "kotlin"; + disabled = false; + detect_extensions = [ + "kt" + "kts" + ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + kubernetes = { + disabled = false; + format = "[$symbol$context( ($namespace))]($style) in "; + style = "cyan bold"; + symbol = "⛵ "; + }; + kubernetes.context_aliases = { }; + line_break = { + disabled = false; + }; + localip = { + disabled = false; + format = "[@$localipv4]($style) "; + ssh_only = false; + style = "yellow bold"; + }; + lua = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🌙 "; + style = "bold blue"; + lua_binary = "lua"; + disabled = false; + detect_extensions = [ "lua" ]; + detect_files = [ ".lua-version" ]; + detect_folders = [ "lua" ]; + }; + memory_usage = { + disabled = false; + format = "$symbol[$ram( | $swap)]($style) "; + style = "white bold dimmed"; + symbol = " "; + # threshold = 75; + threshold = -1; + }; + nim = { + format = "[$symbol($version )]($style)"; + style = "yellow bold bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "nim" + "nims" + "nimble" + ]; + detect_files = [ "nim.cfg" ]; + detect_folders = [ ]; + }; + nix_shell = { + format = "[$symbol$state( ($name))]($style) "; + disabled = false; + impure_msg = "[impure](bold red)"; + pure_msg = "[pure](bold green)"; + style = "bold blue"; + symbol = " "; + }; + nodejs = { + format = "[$symbol($version )]($style)"; + not_capable_style = "bold red"; + style = "bold green bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "js" + "mjs" + "cjs" + "ts" + "mts" + "cts" + ]; + detect_files = [ + "package.json" + ".node-version" + ".nvmrc" + ]; + detect_folders = [ "node_modules" ]; + }; + ocaml = { + format = "[$symbol($version )(($switch_indicator$switch_name) )]($style)"; + global_switch_indicator = ""; + local_switch_indicator = "*"; + style = "bold yellow"; + symbol = "🐫 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "opam" + "ml" + "mli" + "re" + "rei" + ]; + detect_files = [ + "dune" + "dune-project" + "jbuild" + "jbuild-ignore" + ".merlin" + ]; + detect_folders = [ + "_opam" + "esy.lock" + ]; + }; + openstack = { + format = "[$symbol$cloud(($project))]($style) "; + symbol = "☁️ "; + style = "bold yellow"; + disabled = false; + }; + package = { + format = "[$symbol$version]($style) "; + symbol = "📦 "; + style = "208 bold"; + display_private = false; + disabled = false; + version_format = "v$raw"; + }; + perl = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐪 "; + style = "149 bold"; + disabled = false; + detect_extensions = [ + "pl" + "pm" + "pod" + ]; + detect_files = [ + "Makefile.PL" + "Build.PL" + "cpanfile" + "cpanfile.snapshot" + "META.json" + "META.yml" + ".perl-version" + ]; + detect_folders = [ ]; + }; + php = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐘 "; + style = "147 bold"; + disabled = false; + detect_extensions = [ "php" ]; + detect_files = [ + "composer.json" + ".php-version" + ]; + detect_folders = [ ]; + }; + pulumi = { + format = "[$symbol($username@)$stack]($style) "; + version_format = "v$raw"; + symbol = " "; + style = "bold 5"; + disabled = false; + }; + purescript = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "<=> "; + style = "bold white"; + disabled = false; + detect_extensions = [ "purs" ]; + detect_files = [ "spago.dhall" ]; + detect_folders = [ ]; + }; + python = { + format = "[$symbol$pyenv_prefix($version )(($virtualenv) )]($style)"; + python_binary = [ + "python" + "python3" + "python2" + ]; + pyenv_prefix = "pyenv "; + pyenv_version_name = true; + style = "yellow bold"; + symbol = "🐍 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ "py" ]; + detect_files = [ + "requirements.txt" + ".python-version" + "pyproject.toml" + "Pipfile" + "tox.ini" + "setup.py" + "__init__.py" + ]; + detect_folders = [ ]; + }; + red = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔺 "; + style = "red bold"; + disabled = false; + detect_extensions = [ + "red" + "reds" + ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + rlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "blue bold"; + symbol = "📐 "; + disabled = false; + detect_extensions = [ + "R" + "Rd" + "Rmd" + "Rproj" + "Rsx" + ]; + detect_files = [ ".Rprofile" ]; + detect_folders = [ ".Rproj.user" ]; + }; + ruby = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "💎 "; + style = "bold red"; + disabled = false; + detect_extensions = [ "rb" ]; + detect_files = [ + "Gemfile" + ".ruby-version" + ]; + detect_folders = [ ]; + detect_variables = [ + "RUBY_VERSION" + "RBENV_VERSION" + ]; + }; + rust = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦀 "; + style = "bold red bg:0x86BBD8"; + disabled = false; + detect_extensions = [ "rs" ]; + detect_files = [ "Cargo.toml" ]; + detect_folders = [ ]; + }; + scala = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + disabled = false; + style = "red bold"; + symbol = "🆂 "; + detect_extensions = [ + "sbt" + "scala" + ]; + detect_files = [ + ".scalaenv" + ".sbtenv" + "build.sbt" + ]; + detect_folders = [ ".metals" ]; + }; + shell = { + format = "[$indicator]($style) "; + bash_indicator = "bsh"; + cmd_indicator = "cmd"; + elvish_indicator = "esh"; + fish_indicator = ""; + ion_indicator = "ion"; + nu_indicator = "nu"; + powershell_indicator = "_"; + style = "white bold"; + tcsh_indicator = "tsh"; + unknown_indicator = "mystery shell"; + xonsh_indicator = "xsh"; + zsh_indicator = "zsh"; + disabled = false; + }; + shlvl = { + threshold = 2; + format = "[$symbol$shlvl]($style) "; + symbol = "↕️ "; + repeat = false; + style = "bold yellow"; + disabled = true; + }; + singularity = { + format = "[$symbol[$env]]($style) "; + style = "blue bold dimmed"; + symbol = "📦 "; + disabled = false; + }; + spack = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = "🅢 "; + style = "blue bold"; + disabled = false; + }; + status = { + format = "[$symbol$status]($style) "; + map_symbol = true; + not_executable_symbol = "🚫"; + not_found_symbol = "🔍"; + pipestatus = false; + pipestatus_format = "[$pipestatus] => [$symbol$common_meaning$signal_name$maybe_int]($style)"; + pipestatus_separator = "|"; + recognize_signal_code = true; + signal_symbol = "⚡"; + style = "bold red bg:blue"; + success_symbol = "🟢 SUCCESS"; + symbol = "🔴 "; + disabled = true; + }; + sudo = { + format = "[as $symbol]($style)"; + symbol = "🧙 "; + style = "bold blue"; + allow_windows = false; + disabled = true; + }; + swift = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐦 "; + style = "bold 202"; + disabled = false; + detect_extensions = [ "swift" ]; + detect_files = [ "Package.swift" ]; + detect_folders = [ ]; + }; + terraform = { + format = "[$symbol$workspace]($style) "; + version_format = "v$raw"; + symbol = "💠 "; + style = "bold 105"; + disabled = false; + detect_extensions = [ + "tf" + "tfplan" + "tfstate" + ]; + detect_files = [ ]; + detect_folders = [ ".terraform" ]; + }; + time = { + format = "[$symbol $time]($style) "; + style = "bold yellow bg:0x33658A"; + use_12hr = false; + disabled = false; + utc_time_offset = "local"; + # time_format = "%R"; # Hour:Minute Format; + time_format = "%T"; # Hour:Minute:Seconds Format; + time_range = "-"; + }; + username = { + format = "[$user]($style) "; + show_always = true; + style_root = "red bold bg:0x9A348E"; + style_user = "yellow bold bg:0x9A348E"; + disabled = false; + }; + vagrant = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⍱ "; + style = "cyan bold"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ "Vagrantfile" ]; + detect_folders = [ ]; + }; + vcsh = { + symbol = ""; + style = "bold yellow"; + format = "[$symbol$repo]($style) "; + disabled = false; + }; + vlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "V "; + style = "blue bold"; + disabled = false; + detect_extensions = [ "v" ]; + detect_files = [ + "v.mod" + "vpkg.json" + ".vpkg-lock.json" + ]; + detect_folders = [ ]; + }; + zig = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "↯ "; + style = "bold yellow"; + disabled = false; + detect_extensions = [ "zig" ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + custom = { }; }; + }; # https://nix-community.github.io/home-manager/options.html#opt-programs.direnv.config programs.direnv = { diff --git a/templates/start-config/flake.nix b/templates/start-config/flake.nix index 6ff79bf..7d8f6a9 100644 --- a/templates/start-config/flake.nix +++ b/templates/start-config/flake.nix @@ -1,49 +1,50 @@ - { - description = "Home Manager configuration"; +{ + description = "Home Manager configuration"; - inputs = { - # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; - outputs = { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - username = "1M0b4nc0"; - hostname = "fooo"; - in { - homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "1M0b4nc0"; + hostname = "fooo"; + in + { + homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.${system}; - modules = [ - { - home = { - inherit username; - homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! - stateVersion = "22.11"; - }; - programs.home-manager.enable = true; - } - ./home.nix - ]; + modules = [ + { + home = { + inherit username; + homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; - # TODO: how to: Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; + # TODO: how to: Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ - bashInteractive - coreutils - curl - gnumake - patchelf - poetry - python3Full - tmate - ]; - }; + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; }; - } + }; +} diff --git a/templates/start-config/home.nix b/templates/start-config/home.nix index 75c3601..da3cf4b 100644 --- a/templates/start-config/home.nix +++ b/templates/start-config/home.nix @@ -162,65 +162,65 @@ # xkcd-font # (nerdfonts.override { fonts = [ "FiraCode"]; }) - ( - nerdfonts.override { - fonts = [ - # "3270" - # "Agave" - # "AnonymousPro" - # "Arimo" - # "AurulentSansMono" - # "BigBlueTerminal" - # "BitstreamVeraSansMono" - # "CascadiaCode" - # "CodeNewRoman" - # "Cousine" - # "DaddyTimeMono" - # "DejaVuSansMono" - # "DroidSansMono" - # "FantasqueSansMono" - "FiraCode" - # "FiraMono" - # "FontPatcher" - # "Go-Mono" - # "Gohu" - # "Hack" - # "Hasklig" - # "HeavyData" - # "Hermit" - # "iA-Writer" - # "IBMPlexMono" - # "Inconsolata" - # "InconsolataGo" - # "InconsolataLGC" - # "Iosevka" - "JetBrainsMono" - # "Lekton" - # "LiberationMono" - # "Lilex" - # "Meslo" - # "Monofur" - # "Monoid" - # "Mononoki" - # "MPlus" - # "NerdFontsSymbolsOnly" - # "Noto" - # "OpenDyslexic" - # "Overpass" - # "ProFont" - # "ProggyClean" - # "RobotoMono" - # "ShareTechMono" - # "SourceCodePro" - # "SpaceMono" - # "Terminus" - # "Tinos" - "Ubuntu" - # "UbuntuMono" - # "VictorMono" - ]; - } - ) + ( + nerdfonts.override { + fonts = [ + # "3270" + # "Agave" + # "AnonymousPro" + # "Arimo" + # "AurulentSansMono" + # "BigBlueTerminal" + # "BitstreamVeraSansMono" + # "CascadiaCode" + # "CodeNewRoman" + # "Cousine" + # "DaddyTimeMono" + # "DejaVuSansMono" + # "DroidSansMono" + # "FantasqueSansMono" + "FiraCode" + # "FiraMono" + # "FontPatcher" + # "Go-Mono" + # "Gohu" + # "Hack" + # "Hasklig" + # "HeavyData" + # "Hermit" + # "iA-Writer" + # "IBMPlexMono" + # "Inconsolata" + # "InconsolataGo" + # "InconsolataLGC" + # "Iosevka" + "JetBrainsMono" + # "Lekton" + # "LiberationMono" + # "Lilex" + # "Meslo" + # "Monofur" + # "Monoid" + # "Mononoki" + # "MPlus" + # "NerdFontsSymbolsOnly" + # "Noto" + # "OpenDyslexic" + # "Overpass" + # "ProFont" + # "ProggyClean" + # "RobotoMono" + # "ShareTechMono" + # "SourceCodePro" + # "SpaceMono" + # "Terminus" + # "Tinos" + "Ubuntu" + # "UbuntuMono" + # "VictorMono" + ]; + } + ) # zsh-nix-shell # zsh-powerlevel10k @@ -260,101 +260,101 @@ # slirp4netns # shadow - ( - writeScriptBin "ix" '' - #! ${pkgs.runtimeShell} -e - "$@" | "curl" -F 'f:1=<-' ix.io - '' - ) - - ( - writeScriptBin "erw" '' - #! ${pkgs.runtimeShell} -e - echo "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "crw" '' - #! ${pkgs.runtimeShell} -e - cat "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "myexternalip" '' - #! ${pkgs.runtimeShell} -e - # https://askubuntu.com/questions/95910/command-for-determining-my-public-ip#comment1985064_712144 - - curl https://checkip.amazonaws.com - '' - ) - - ( - writeScriptBin "mynatip" '' - #! ${pkgs.runtimeShell} -e - # https://unix.stackexchange.com/a/569306 - # https://serverfault.com/a/256506 - - NETWORK_INTERFACE_NAME=$(route | awk ' - BEGIN { min = -1 } - $1 == "default" { - if (min < 0 || $5 < min) { - min = $5 - iface = $8 - } - } - END { - if (iface == "") { - print "No \"default\" route found!" > "/dev/stderr" - exit 1 - } else { - print iface - exit 0 - } - } - ' - ) - - ip addr show dev $NETWORK_INTERFACE_NAME | grep "inet " | awk '{ print $2 }' | cut -d'/' -f1 - '' - ) - - ( - writeScriptBin "generate-new-ed25519-key-pair" '' - #! ${pkgs.runtimeShell} -e - ssh-keygen \ - -t ed25519 \ - -C "$(git config user.email)" \ - -f "$HOME"/.ssh/id_ed25519 \ - -N "" \ - && echo \ - && cat "$HOME"/.ssh/id_ed25519.pub \ - && echo - - - while $(echo 'yes' | ssh -T -o ConnectTimeout=1 git@github.com &>/dev/null); do echo $(date +'%d/%m/%Y %H:%M:%S:%3N') && sleep 0.5; done - - ssh -T -o ConnectTimeout=1 git@github.com &>/dev/null - test $? -eq 1 || echo "Error in ssh -T -o ConnectTimeout=1 git@github.com - - '' - ) - - ( - writeScriptBin "try-install-openssh-server" '' - #! ${pkgs.runtimeShell} -e - command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) - command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) - '' - ) - - ( - writeScriptBin "nfm" '' - #! ${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "myexternalip" '' + #! ${pkgs.runtimeShell} -e + # https://askubuntu.com/questions/95910/command-for-determining-my-public-ip#comment1985064_712144 + + curl https://checkip.amazonaws.com + '' + ) + + ( + writeScriptBin "mynatip" '' + #! ${pkgs.runtimeShell} -e + # https://unix.stackexchange.com/a/569306 + # https://serverfault.com/a/256506 + + NETWORK_INTERFACE_NAME=$(route | awk ' + BEGIN { min = -1 } + $1 == "default" { + if (min < 0 || $5 < min) { + min = $5 + iface = $8 + } + } + END { + if (iface == "") { + print "No \"default\" route found!" > "/dev/stderr" + exit 1 + } else { + print iface + exit 0 + } + } + ' + ) + + ip addr show dev $NETWORK_INTERFACE_NAME | grep "inet " | awk '{ print $2 }' | cut -d'/' -f1 + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "$HOME"/.ssh/id_ed25519 \ + -N "" \ + && echo \ + && cat "$HOME"/.ssh/id_ed25519.pub \ + && echo + + + while $(echo 'yes' | ssh -T -o ConnectTimeout=1 git@github.com &>/dev/null); do echo $(date +'%d/%m/%Y %H:%M:%S:%3N') && sleep 0.5; done + + ssh -T -o ConnectTimeout=1 git@github.com &>/dev/null + test $? -eq 1 || echo "Error in ssh -T -o ConnectTimeout=1 git@github.com + + '' + ) + + ( + writeScriptBin "try-install-openssh-server" '' + #! ${pkgs.runtimeShell} -e + command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) + command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) ( writeScriptBin "hms" '' @@ -375,28 +375,28 @@ '' ) - ( - writeScriptBin "build-pulling-all-from-cache" '' - #! ${pkgs.runtimeShell} -e - - set -x - - export NIXPKGS_ALLOW_UNFREE=1 - - nix \ - --option eval-cache false \ - --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - build \ - --impure \ - --keep-failed \ - --max-jobs 0 \ - --no-link \ - --print-build-logs \ - --print-out-paths \ - ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage - '' - ) + ( + writeScriptBin "build-pulling-all-from-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + export NIXPKGS_ALLOW_UNFREE=1 + + nix \ + --option eval-cache false \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ + build \ + --impure \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + '' + ) ( writeScriptBin "gphms-cache" '' @@ -696,910 +696,909 @@ # https://gist.github.com/s-a-c/0e44dc7766922308924812d4c019b109 # https://gist.github.com/search?q=So+either+put+%22Important+Documents%22+before+%22Documents%22+or+use+the+substituted+version%3A%3B&ref=searchresults programs.starship = { - enable = true; - enableZshIntegration = true; - settings = { - # "$schema" = "https://starship.rs/config-schema.json"; - add_newline = true; - command_timeout = 500; - continuation_prompt = "[∙](bright-black) "; - # format = "[](0x9A348E)$username$hostname$localip$shlvl$singularity$kubernetes[](fg:0x9A348E bg:0xDA627D)$directory$vcsh[](fg:0xDA627D bg:0xFCA17D)$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch[](fg:0x86BBD8 bg:0x06969A)$docker_context$package$buf[](fg:0xFCA17D bg:0x86BBD8)$c$cmake$cobol$container$daml$dart$deno$dotnet$elixir$elm$erlang$golang$haskell$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$nix_shell$conda$spack$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery[](fg:0x06969A bg:0x33658A)$time$status$shell$character"; - right_format = ""; - scan_timeout = 30; - aws = { - format = "[$symbol($profile )(($region) )([$duration] )]($style)"; - symbol = "🅰 "; - style = "bold yellow"; - disabled = false; - expiration_symbol = "X"; - force_display = false; - }; - aws.region_aliases = {}; - aws.profile_aliases = {}; - azure = { - format = "[$symbol($subscription)([$duration])]($style) "; - symbol = "ﴃ "; - style = "blue bold"; - disabled = true; - }; - battery = { - format = "[$symbol$percentage]($style) "; - charging_symbol = " "; - discharging_symbol = " "; - empty_symbol = " "; - full_symbol = " "; - unknown_symbol = " "; - disabled = false; - display = [ - { - style = "red bold"; - threshold = 10; - } - ]; - }; - buf = { - format = "[$symbol ($version)]($style)"; - version_format = "v$raw"; - symbol = ""; - style = "bold blue"; - disabled = false; - detect_extensions = []; - detect_files = [ - "buf.yaml" - "buf.gen.yaml" - "buf.work.yaml" - ]; - detect_folders = []; - }; - c = { - format = "[$symbol($version(-$name) )]($style)"; - version_format = "v$raw"; - style = "fg:149 bold bg:0x86BBD8"; - symbol = " "; - disabled = false; - detect_extensions = [ - "c" - "h" - ]; - detect_files = []; - detect_folders = []; -# commands = [ -# [ -# "cc" -# "--version" -# ] -# [ -# "gcc" -# "--version" -# ] -# [ -# "clang" -# "--version" -# ] -# ]; - }; - character = { - format = "$symbol "; - vicmd_symbol = "[❮](bold green)"; - disabled = false; - success_symbol = "[➜](bold green) "; - error_symbol = "[✗](bold red) "; - }; - cmake = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "△ "; - style = "bold blue"; - disabled = false; - detect_extensions = []; - detect_files = [ - "CMakeLists.txt" - "CMakeCache.txt" - ]; - detect_folders = []; - }; - cmd_duration = { - min_time = 2000; - format = "⏱ [$duration]($style) "; - style = "yellow bold"; - show_milliseconds = false; - disabled = false; - show_notifications = false; - min_time_to_notify = 45000; - }; - cobol = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "⚙️ "; - style = "bold blue"; - disabled = false; - detect_extensions = [ - "cbl" - "cob" - "CBL" - "COB" - ]; - detect_files = []; - detect_folders = []; - }; - conda = { - truncation_length = 1; - format = "[$symbol$environment]($style) "; - symbol = " "; - style = "green bold"; - ignore_base = true; - disabled = false; - }; - container = { - format = "[$symbol [$name]]($style) "; - symbol = "⬢"; - style = "red bold dimmed"; - disabled = false; - }; - crystal = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🔮 "; - style = "bold red"; - disabled = false; - detect_extensions = ["cr"]; - detect_files = ["shard.yml"]; - detect_folders = []; - }; - dart = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🎯 "; - style = "bold blue"; - disabled = false; - detect_extensions = ["dart"]; - detect_files = [ - "pubspec.yaml" - "pubspec.yml" - "pubspec.lock" - ]; - detect_folders = [".dart_tool"]; - }; - deno = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🦕 "; - style = "green bold"; - disabled = false; - detect_extensions = []; - detect_files = [ - "deno.json" - "deno.jsonc" - "mod.ts" - "deps.ts" - "mod.js" - "deps.js" - ]; - detect_folders = []; - }; - directory = { - disabled = false; - fish_style_pwd_dir_length = 0; - format = "[$path]($style)[$read_only]($read_only_style) "; - home_symbol = "~"; - read_only = " "; - read_only_style = "red"; - repo_root_format = "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; - style = "cyan bold bg:0xDA627D"; - truncate_to_repo = true; - truncation_length = 3; - truncation_symbol = "…/"; - use_logical_path = true; - use_os_path_sep = true; - }; - directory.substitutions = { - # Here is how you can shorten some long paths by text replacement; - # similar to mapped_locations in Oh My Posh:; - "Documents" = " "; - "Downloads" = " "; - "Music" = " "; - "Pictures" = " "; - # Keep in mind that the order matters. For example:; - # "Important Documents" = "  "; - # will not be replaced, because "Documents" was already substituted before.; - # So either put "Important Documents" before "Documents" or use the substituted version:; - # "Important  " = "  "; - "Important " = " "; - }; - docker_context = { - format = "[$symbol$context]($style) "; - style = "blue bold bg:0x06969A"; - symbol = " "; - only_with_files = true; - disabled = false; - detect_extensions = []; - detect_files = [ - "docker-compose.yml" - "docker-compose.yaml" - "Dockerfile" - ]; - detect_folders = []; - }; - dotnet = { - format = "[$symbol($version )(🎯 $tfm )]($style)"; - version_format = "v$raw"; - symbol = "🥅 "; - style = "blue bold"; - heuristic = true; - disabled = false; - detect_extensions = [ - "csproj" - "fsproj" - "xproj" - ]; - detect_files = [ - "global.json" - "project.json" - "Directory.Build.props" - "Directory.Build.targets" - "Packages.props" - ]; - detect_folders = []; - }; - elixir = { - format = "[$symbol($version (OTP $otp_version) )]($style)"; - version_format = "v$raw"; - style = "bold purple bg:0x86BBD8"; - symbol = " "; - disabled = false; - detect_extensions = []; - detect_files = ["mix.exs"]; - detect_folders = []; - }; - elm = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - style = "cyan bold bg:0x86BBD8"; - symbol = " "; - disabled = false; - detect_extensions = ["elm"]; - detect_files = [ - "elm.json" - "elm-package.json" - ".elm-version" - ]; - detect_folders = ["elm-stuff"]; - }; - env_var = {}; - env_var.SHELL = { - format = "[$symbol($env_value )]($style)"; - style = "grey bold italic dimmed"; - symbol = "e:"; - disabled = true; - variable = "SHELL"; - default = "unknown shell"; - }; - env_var.USER = { - format = "[$symbol($env_value )]($style)"; - style = "grey bold italic dimmed"; - symbol = "e:"; - disabled = true; - default = "unknown user"; - }; - erlang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = " "; - style = "bold red"; - disabled = false; - detect_extensions = []; - detect_files = [ - "rebar.config" - "erlang.mk" - ]; - detect_folders = []; - }; - fill = { - style = "bold black"; - symbol = "."; - disabled = false; - }; - gcloud = { - format = "[$symbol$account(@$domain)(($region))(($project))]($style) "; - symbol = "☁️ "; - style = "bold blue"; - disabled = false; - }; - gcloud.project_aliases = {}; - gcloud.region_aliases = {}; - git_branch = { - format = "[$symbol$branch(:$remote_branch)]($style) "; - symbol = " "; - style = "bold purple bg:0xFCA17D"; - truncation_length = 9223372036854775807; - truncation_symbol = "…"; - only_attached = false; - always_show_remote = false; - ignore_branches = []; - disabled = false; - }; - git_commit = { - commit_hash_length = 7; - format = "[($hash$tag)]($style) "; - style = "green bold"; - only_detached = true; - disabled = false; - tag_symbol = " 🏷 "; - tag_disabled = true; - }; - git_metrics = { - added_style = "bold green"; - deleted_style = "bold red"; - only_nonzero_diffs = true; - format = "([+$added]($added_style) )([-$deleted]($deleted_style) )"; - disabled = false; - }; - git_state = { - am = "AM"; - am_or_rebase = "AM/REBASE"; - bisect = "BISECTING"; - cherry_pick = "🍒PICKING(bold red)"; - disabled = false; - format = "([$state( $progress_current/$progress_total)]($style)) "; - merge = "MERGING"; - rebase = "REBASING"; - revert = "REVERTING"; - style = "bold yellow"; - }; - git_status = { - ahead = "🏎💨$count"; - behind = "😰$count"; - conflicted = "🏳"; - deleted = "🗑"; - disabled = false; - diverged = "😵"; - # format = "([[$all_status$ahead_behind]]($style) )"; - ignore_submodules = false; - modified = "📝"; - renamed = "👅"; - staged = "[++($count)](green)"; - stashed = "📦"; - style = "red bold bg:0xFCA17D"; - untracked = "🤷"; - up_to_date = "✓"; - }; - golang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = " "; - style = "bold cyan bg:0x86BBD8"; - disabled = false; - detect_extensions = ["go"]; - detect_files = [ - "go.mod" - "go.sum" - "glide.yaml" - "Gopkg.yml" - "Gopkg.lock" - ".go-version" - ]; - detect_folders = ["Godeps"]; - }; - haskell = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "λ "; - style = "bold purple bg:0x86BBD8"; - disabled = false; - detect_extensions = [ - "hs" - "cabal" - "hs-boot" - ]; - detect_files = [ - "stack.yaml" - "cabal.project" - ]; - detect_folders = []; - }; - helm = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "⎈ "; - style = "bold white"; - disabled = false; - detect_extensions = []; - detect_files = [ - "helmfile.yaml" - "Chart.yaml" - ]; - detect_folders = []; - }; - hg_branch = { - symbol = " "; - style = "bold purple"; - format = "on [$symbol$branch]($style) "; - truncation_length = 9223372036854775807; - truncation_symbol = "…"; - disabled = true; - }; - hostname = { - disabled = false; - format = "[$ssh_symbol](blue dimmed bold)[$hostname]($style) "; - ssh_only = false; - style = "green dimmed bold"; - trim_at = "."; - }; - java = { - disabled = false; - format = "[$symbol($version )]($style)"; - style = "red dimmed bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - detect_extensions = [ - "java" - "class" - "jar" - "gradle" - "clj" - "cljc" - ]; - detect_files = [ - "pom.xml" - "build.gradle.kts" - "build.sbt" - ".java-version" - "deps.edn" - "project.clj" - "build.boot" - ]; - detect_folders = []; - }; - jobs = { - threshold = 1; - symbol_threshold = 0; - number_threshold = 2; - format = "[$symbol$number]($style) "; - symbol = "✦"; - style = "bold blue"; - disabled = false; - }; - julia = { - disabled = false; - format = "[$symbol($version )]($style)"; - style = "bold purple bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - detect_extensions = ["jl"]; - detect_files = [ - "Project.toml" - "Manifest.toml" - ]; - detect_folders = []; - }; - kotlin = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🅺 "; - style = "bold blue"; - kotlin_binary = "kotlin"; - disabled = false; - detect_extensions = [ - "kt" - "kts" - ]; - detect_files = []; - detect_folders = []; - }; - kubernetes = { - disabled = false; - format = "[$symbol$context( ($namespace))]($style) in "; - style = "cyan bold"; - symbol = "⛵ "; - }; - kubernetes.context_aliases = {}; - line_break = { - disabled = false; - }; - localip = { - disabled = false; - format = "[@$localipv4]($style) "; - ssh_only = false; - style = "yellow bold"; - }; - lua = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🌙 "; - style = "bold blue"; - lua_binary = "lua"; - disabled = false; - detect_extensions = ["lua"]; - detect_files = [".lua-version"]; - detect_folders = ["lua"]; - }; - memory_usage = { - disabled = false; - format = "$symbol[$ram( | $swap)]($style) "; - style = "white bold dimmed"; - symbol = " "; - # threshold = 75; - threshold = -1; - }; - nim = { - format = "[$symbol($version )]($style)"; - style = "yellow bold bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - disabled = false; - detect_extensions = [ - "nim" - "nims" - "nimble" - ]; - detect_files = ["nim.cfg"]; - detect_folders = []; - }; - nix_shell = { - format = "[$symbol$state( ($name))]($style) "; - disabled = false; - impure_msg = "[impure](bold red)"; - pure_msg = "[pure](bold green)"; - style = "bold blue"; - symbol = " "; - }; - nodejs = { - format = "[$symbol($version )]($style)"; - not_capable_style = "bold red"; - style = "bold green bg:0x86BBD8"; - symbol = " "; - version_format = "v$raw"; - disabled = false; - detect_extensions = [ - "js" - "mjs" - "cjs" - "ts" - "mts" - "cts" - ]; - detect_files = [ - "package.json" - ".node-version" - ".nvmrc" - ]; - detect_folders = ["node_modules"]; - }; - ocaml = { - format = "[$symbol($version )(($switch_indicator$switch_name) )]($style)"; - global_switch_indicator = ""; - local_switch_indicator = "*"; - style = "bold yellow"; - symbol = "🐫 "; - version_format = "v$raw"; - disabled = false; - detect_extensions = [ - "opam" - "ml" - "mli" - "re" - "rei" - ]; - detect_files = [ - "dune" - "dune-project" - "jbuild" - "jbuild-ignore" - ".merlin" - ]; - detect_folders = [ - "_opam" - "esy.lock" - ]; - }; - openstack = { - format = "[$symbol$cloud(($project))]($style) "; - symbol = "☁️ "; - style = "bold yellow"; - disabled = false; - }; - package = { - format = "[$symbol$version]($style) "; - symbol = "📦 "; - style = "208 bold"; - display_private = false; - disabled = false; - version_format = "v$raw"; - }; - perl = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🐪 "; - style = "149 bold"; - disabled = false; - detect_extensions = [ - "pl" - "pm" - "pod" - ]; - detect_files = [ - "Makefile.PL" - "Build.PL" - "cpanfile" - "cpanfile.snapshot" - "META.json" - "META.yml" - ".perl-version" - ]; - detect_folders = []; - }; - php = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🐘 "; - style = "147 bold"; - disabled = false; - detect_extensions = ["php"]; - detect_files = [ - "composer.json" - ".php-version" - ]; - detect_folders = []; - }; - pulumi = { - format = "[$symbol($username@)$stack]($style) "; - version_format = "v$raw"; - symbol = " "; - style = "bold 5"; - disabled = false; - }; - purescript = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "<=> "; - style = "bold white"; - disabled = false; - detect_extensions = ["purs"]; - detect_files = ["spago.dhall"]; - detect_folders = []; - }; - python = { - format = "[$symbol$pyenv_prefix($version )(($virtualenv) )]($style)"; - python_binary = [ - "python" - "python3" - "python2" - ]; - pyenv_prefix = "pyenv "; - pyenv_version_name = true; - style = "yellow bold"; - symbol = "🐍 "; - version_format = "v$raw"; - disabled = false; - detect_extensions = ["py"]; - detect_files = [ - "requirements.txt" - ".python-version" - "pyproject.toml" - "Pipfile" - "tox.ini" - "setup.py" - "__init__.py" - ]; - detect_folders = []; - }; - red = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🔺 "; - style = "red bold"; - disabled = false; - detect_extensions = [ - "red" - "reds" - ]; - detect_files = []; - detect_folders = []; - }; - rlang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - style = "blue bold"; - symbol = "📐 "; - disabled = false; - detect_extensions = [ - "R" - "Rd" - "Rmd" - "Rproj" - "Rsx" - ]; - detect_files = [".Rprofile"]; - detect_folders = [".Rproj.user"]; - }; - ruby = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "💎 "; - style = "bold red"; - disabled = false; - detect_extensions = ["rb"]; - detect_files = [ - "Gemfile" - ".ruby-version" - ]; - detect_folders = []; - detect_variables = [ - "RUBY_VERSION" - "RBENV_VERSION" - ]; - }; - rust = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🦀 "; - style = "bold red bg:0x86BBD8"; - disabled = false; - detect_extensions = ["rs"]; - detect_files = ["Cargo.toml"]; - detect_folders = []; - }; - scala = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - disabled = false; - style = "red bold"; - symbol = "🆂 "; - detect_extensions = [ - "sbt" - "scala" - ]; - detect_files = [ - ".scalaenv" - ".sbtenv" - "build.sbt" - ]; - detect_folders = [".metals"]; - }; - shell = { - format = "[$indicator]($style) "; - bash_indicator = "bsh"; - cmd_indicator = "cmd"; - elvish_indicator = "esh"; - fish_indicator = ""; - ion_indicator = "ion"; - nu_indicator = "nu"; - powershell_indicator = "_"; - style = "white bold"; - tcsh_indicator = "tsh"; - unknown_indicator = "mystery shell"; - xonsh_indicator = "xsh"; - zsh_indicator = "zsh"; - disabled = false; - }; - shlvl = { - threshold = 2; - format = "[$symbol$shlvl]($style) "; - symbol = "↕️ "; - repeat = false; - style = "bold yellow"; - disabled = true; - }; - singularity = { - format = "[$symbol[$env]]($style) "; - style = "blue bold dimmed"; - symbol = "📦 "; - disabled = false; - }; - spack = { - truncation_length = 1; - format = "[$symbol$environment]($style) "; - symbol = "🅢 "; - style = "blue bold"; - disabled = false; - }; - status = { - format = "[$symbol$status]($style) "; - map_symbol = true; - not_executable_symbol = "🚫"; - not_found_symbol = "🔍"; - pipestatus = false; - pipestatus_format = "[$pipestatus] => [$symbol$common_meaning$signal_name$maybe_int]($style)"; - pipestatus_separator = "|"; - recognize_signal_code = true; - signal_symbol = "⚡"; - style = "bold red bg:blue"; - success_symbol = "🟢 SUCCESS"; - symbol = "🔴 "; - disabled = true; - }; - sudo = { - format = "[as $symbol]($style)"; - symbol = "🧙 "; - style = "bold blue"; - allow_windows = false; - disabled = true; - }; - swift = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "🐦 "; - style = "bold 202"; - disabled = false; - detect_extensions = ["swift"]; - detect_files = ["Package.swift"]; - detect_folders = []; - }; - terraform = { - format = "[$symbol$workspace]($style) "; - version_format = "v$raw"; - symbol = "💠 "; - style = "bold 105"; - disabled = false; - detect_extensions = [ - "tf" - "tfplan" - "tfstate" - ]; - detect_files = []; - detect_folders = [".terraform"]; - }; - time = { - format = "[$symbol $time]($style) "; - style = "bold yellow bg:0x33658A"; - use_12hr = false; - disabled = false; - utc_time_offset = "local"; - # time_format = "%R"; # Hour:Minute Format; - time_format = "%T"; # Hour:Minute:Seconds Format; - time_range = "-"; - }; - username = { - format = "[$user]($style) "; - show_always = true; - style_root = "red bold bg:0x9A348E"; - style_user = "yellow bold bg:0x9A348E"; - disabled = false; - }; - vagrant = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "⍱ "; - style = "cyan bold"; - disabled = false; - detect_extensions = []; - detect_files = ["Vagrantfile"]; - detect_folders = []; - }; - vcsh = { - symbol = ""; - style = "bold yellow"; - format = "[$symbol$repo]($style) "; - disabled = false; - }; - vlang = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "V "; - style = "blue bold"; - disabled = false; - detect_extensions = ["v"]; - detect_files = [ - "v.mod" - "vpkg.json" - ".vpkg-lock.json" - ]; - detect_folders = []; - }; - zig = { - format = "[$symbol($version )]($style)"; - version_format = "v$raw"; - symbol = "↯ "; - style = "bold yellow"; - disabled = false; - detect_extensions = ["zig"]; - detect_files = []; - detect_folders = []; - }; - custom = { - }; + enable = true; + enableZshIntegration = true; + settings = { + # "$schema" = "https://starship.rs/config-schema.json"; + add_newline = true; + command_timeout = 500; + continuation_prompt = "[∙](bright-black) "; + # format = "[](0x9A348E)$username$hostname$localip$shlvl$singularity$kubernetes[](fg:0x9A348E bg:0xDA627D)$directory$vcsh[](fg:0xDA627D bg:0xFCA17D)$git_branch$git_commit$git_state$git_metrics$git_status$hg_branch[](fg:0x86BBD8 bg:0x06969A)$docker_context$package$buf[](fg:0xFCA17D bg:0x86BBD8)$c$cmake$cobol$container$daml$dart$deno$dotnet$elixir$elm$erlang$golang$haskell$helm$java$julia$kotlin$lua$nim$nodejs$ocaml$perl$php$pulumi$purescript$python$rlang$red$ruby$rust$scala$swift$terraform$vlang$vagrant$zig$nix_shell$conda$spack$memory_usage$aws$gcloud$openstack$azure$env_var$crystal$custom$sudo$cmd_duration$line_break$jobs$battery[](fg:0x06969A bg:0x33658A)$time$status$shell$character"; + right_format = ""; + scan_timeout = 30; + aws = { + format = "[$symbol($profile )(($region) )([$duration] )]($style)"; + symbol = "🅰 "; + style = "bold yellow"; + disabled = false; + expiration_symbol = "X"; + force_display = false; + }; + aws.region_aliases = { }; + aws.profile_aliases = { }; + azure = { + format = "[$symbol($subscription)([$duration])]($style) "; + symbol = "ﴃ "; + style = "blue bold"; + disabled = true; + }; + battery = { + format = "[$symbol$percentage]($style) "; + charging_symbol = " "; + discharging_symbol = " "; + empty_symbol = " "; + full_symbol = " "; + unknown_symbol = " "; + disabled = false; + display = [ + { + style = "red bold"; + threshold = 10; + } + ]; + }; + buf = { + format = "[$symbol ($version)]($style)"; + version_format = "v$raw"; + symbol = ""; + style = "bold blue"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "buf.yaml" + "buf.gen.yaml" + "buf.work.yaml" + ]; + detect_folders = [ ]; + }; + c = { + format = "[$symbol($version(-$name) )]($style)"; + version_format = "v$raw"; + style = "fg:149 bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ + "c" + "h" + ]; + detect_files = [ ]; + detect_folders = [ ]; + # commands = [ + # [ + # "cc" + # "--version" + # ] + # [ + # "gcc" + # "--version" + # ] + # [ + # "clang" + # "--version" + # ] + # ]; + }; + character = { + format = "$symbol "; + vicmd_symbol = "[❮](bold green)"; + disabled = false; + success_symbol = "[➜](bold green) "; + error_symbol = "[✗](bold red) "; + }; + cmake = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "△ "; + style = "bold blue"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "CMakeLists.txt" + "CMakeCache.txt" + ]; + detect_folders = [ ]; + }; + cmd_duration = { + min_time = 2000; + format = "⏱ [$duration]($style) "; + style = "yellow bold"; + show_milliseconds = false; + disabled = false; + show_notifications = false; + min_time_to_notify = 45000; + }; + cobol = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⚙️ "; + style = "bold blue"; + disabled = false; + detect_extensions = [ + "cbl" + "cob" + "CBL" + "COB" + ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + conda = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = " "; + style = "green bold"; + ignore_base = true; + disabled = false; }; + container = { + format = "[$symbol [$name]]($style) "; + symbol = "⬢"; + style = "red bold dimmed"; + disabled = false; + }; + crystal = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔮 "; + style = "bold red"; + disabled = false; + detect_extensions = [ "cr" ]; + detect_files = [ "shard.yml" ]; + detect_folders = [ ]; + }; + dart = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🎯 "; + style = "bold blue"; + disabled = false; + detect_extensions = [ "dart" ]; + detect_files = [ + "pubspec.yaml" + "pubspec.yml" + "pubspec.lock" + ]; + detect_folders = [ ".dart_tool" ]; + }; + deno = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦕 "; + style = "green bold"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "deno.json" + "deno.jsonc" + "mod.ts" + "deps.ts" + "mod.js" + "deps.js" + ]; + detect_folders = [ ]; + }; + directory = { + disabled = false; + fish_style_pwd_dir_length = 0; + format = "[$path]($style)[$read_only]($read_only_style) "; + home_symbol = "~"; + read_only = " "; + read_only_style = "red"; + repo_root_format = "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; + style = "cyan bold bg:0xDA627D"; + truncate_to_repo = true; + truncation_length = 3; + truncation_symbol = "…/"; + use_logical_path = true; + use_os_path_sep = true; + }; + directory.substitutions = { + # Here is how you can shorten some long paths by text replacement; + # similar to mapped_locations in Oh My Posh:; + "Documents" = " "; + "Downloads" = " "; + "Music" = " "; + "Pictures" = " "; + # Keep in mind that the order matters. For example:; + # "Important Documents" = "  "; + # will not be replaced, because "Documents" was already substituted before.; + # So either put "Important Documents" before "Documents" or use the substituted version:; + # "Important  " = "  "; + "Important " = " "; + }; + docker_context = { + format = "[$symbol$context]($style) "; + style = "blue bold bg:0x06969A"; + symbol = " "; + only_with_files = true; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "docker-compose.yml" + "docker-compose.yaml" + "Dockerfile" + ]; + detect_folders = [ ]; + }; + dotnet = { + format = "[$symbol($version )(🎯 $tfm )]($style)"; + version_format = "v$raw"; + symbol = "🥅 "; + style = "blue bold"; + heuristic = true; + disabled = false; + detect_extensions = [ + "csproj" + "fsproj" + "xproj" + ]; + detect_files = [ + "global.json" + "project.json" + "Directory.Build.props" + "Directory.Build.targets" + "Packages.props" + ]; + detect_folders = [ ]; + }; + elixir = { + format = "[$symbol($version (OTP $otp_version) )]($style)"; + version_format = "v$raw"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ ]; + detect_files = [ "mix.exs" ]; + detect_folders = [ ]; + }; + elm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "cyan bold bg:0x86BBD8"; + symbol = " "; + disabled = false; + detect_extensions = [ "elm" ]; + detect_files = [ + "elm.json" + "elm-package.json" + ".elm-version" + ]; + detect_folders = [ "elm-stuff" ]; + }; + env_var = { }; + env_var.SHELL = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + variable = "SHELL"; + default = "unknown shell"; + }; + env_var.USER = { + format = "[$symbol($env_value )]($style)"; + style = "grey bold italic dimmed"; + symbol = "e:"; + disabled = true; + default = "unknown user"; + }; + erlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold red"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "rebar.config" + "erlang.mk" + ]; + detect_folders = [ ]; + }; + fill = { + style = "bold black"; + symbol = "."; + disabled = false; + }; + gcloud = { + format = "[$symbol$account(@$domain)(($region))(($project))]($style) "; + symbol = "☁️ "; + style = "bold blue"; + disabled = false; + }; + gcloud.project_aliases = { }; + gcloud.region_aliases = { }; + git_branch = { + format = "[$symbol$branch(:$remote_branch)]($style) "; + symbol = " "; + style = "bold purple bg:0xFCA17D"; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + only_attached = false; + always_show_remote = false; + ignore_branches = [ ]; + disabled = false; + }; + git_commit = { + commit_hash_length = 7; + format = "[($hash$tag)]($style) "; + style = "green bold"; + only_detached = true; + disabled = false; + tag_symbol = " 🏷 "; + tag_disabled = true; + }; + git_metrics = { + added_style = "bold green"; + deleted_style = "bold red"; + only_nonzero_diffs = true; + format = "([+$added]($added_style) )([-$deleted]($deleted_style) )"; + disabled = false; + }; + git_state = { + am = "AM"; + am_or_rebase = "AM/REBASE"; + bisect = "BISECTING"; + cherry_pick = "🍒PICKING(bold red)"; + disabled = false; + format = "([$state( $progress_current/$progress_total)]($style)) "; + merge = "MERGING"; + rebase = "REBASING"; + revert = "REVERTING"; + style = "bold yellow"; + }; + git_status = { + ahead = "🏎💨$count"; + behind = "😰$count"; + conflicted = "🏳"; + deleted = "🗑"; + disabled = false; + diverged = "😵"; + # format = "([[$all_status$ahead_behind]]($style) )"; + ignore_submodules = false; + modified = "📝"; + renamed = "👅"; + staged = "[++($count)](green)"; + stashed = "📦"; + style = "red bold bg:0xFCA17D"; + untracked = "🤷"; + up_to_date = "✓"; + }; + golang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = " "; + style = "bold cyan bg:0x86BBD8"; + disabled = false; + detect_extensions = [ "go" ]; + detect_files = [ + "go.mod" + "go.sum" + "glide.yaml" + "Gopkg.yml" + "Gopkg.lock" + ".go-version" + ]; + detect_folders = [ "Godeps" ]; + }; + haskell = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "λ "; + style = "bold purple bg:0x86BBD8"; + disabled = false; + detect_extensions = [ + "hs" + "cabal" + "hs-boot" + ]; + detect_files = [ + "stack.yaml" + "cabal.project" + ]; + detect_folders = [ ]; + }; + helm = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⎈ "; + style = "bold white"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ + "helmfile.yaml" + "Chart.yaml" + ]; + detect_folders = [ ]; + }; + hg_branch = { + symbol = " "; + style = "bold purple"; + format = "on [$symbol$branch]($style) "; + truncation_length = 9223372036854775807; + truncation_symbol = "…"; + disabled = true; + }; + hostname = { + disabled = false; + format = "[$ssh_symbol](blue dimmed bold)[$hostname]($style) "; + ssh_only = false; + style = "green dimmed bold"; + trim_at = "."; + }; + java = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "red dimmed bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = [ + "java" + "class" + "jar" + "gradle" + "clj" + "cljc" + ]; + detect_files = [ + "pom.xml" + "build.gradle.kts" + "build.sbt" + ".java-version" + "deps.edn" + "project.clj" + "build.boot" + ]; + detect_folders = [ ]; + }; + jobs = { + threshold = 1; + symbol_threshold = 0; + number_threshold = 2; + format = "[$symbol$number]($style) "; + symbol = "✦"; + style = "bold blue"; + disabled = false; + }; + julia = { + disabled = false; + format = "[$symbol($version )]($style)"; + style = "bold purple bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + detect_extensions = [ "jl" ]; + detect_files = [ + "Project.toml" + "Manifest.toml" + ]; + detect_folders = [ ]; + }; + kotlin = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🅺 "; + style = "bold blue"; + kotlin_binary = "kotlin"; + disabled = false; + detect_extensions = [ + "kt" + "kts" + ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + kubernetes = { + disabled = false; + format = "[$symbol$context( ($namespace))]($style) in "; + style = "cyan bold"; + symbol = "⛵ "; + }; + kubernetes.context_aliases = { }; + line_break = { + disabled = false; + }; + localip = { + disabled = false; + format = "[@$localipv4]($style) "; + ssh_only = false; + style = "yellow bold"; + }; + lua = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🌙 "; + style = "bold blue"; + lua_binary = "lua"; + disabled = false; + detect_extensions = [ "lua" ]; + detect_files = [ ".lua-version" ]; + detect_folders = [ "lua" ]; + }; + memory_usage = { + disabled = false; + format = "$symbol[$ram( | $swap)]($style) "; + style = "white bold dimmed"; + symbol = " "; + # threshold = 75; + threshold = -1; + }; + nim = { + format = "[$symbol($version )]($style)"; + style = "yellow bold bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "nim" + "nims" + "nimble" + ]; + detect_files = [ "nim.cfg" ]; + detect_folders = [ ]; + }; + nix_shell = { + format = "[$symbol$state( ($name))]($style) "; + disabled = false; + impure_msg = "[impure](bold red)"; + pure_msg = "[pure](bold green)"; + style = "bold blue"; + symbol = " "; + }; + nodejs = { + format = "[$symbol($version )]($style)"; + not_capable_style = "bold red"; + style = "bold green bg:0x86BBD8"; + symbol = " "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "js" + "mjs" + "cjs" + "ts" + "mts" + "cts" + ]; + detect_files = [ + "package.json" + ".node-version" + ".nvmrc" + ]; + detect_folders = [ "node_modules" ]; + }; + ocaml = { + format = "[$symbol($version )(($switch_indicator$switch_name) )]($style)"; + global_switch_indicator = ""; + local_switch_indicator = "*"; + style = "bold yellow"; + symbol = "🐫 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ + "opam" + "ml" + "mli" + "re" + "rei" + ]; + detect_files = [ + "dune" + "dune-project" + "jbuild" + "jbuild-ignore" + ".merlin" + ]; + detect_folders = [ + "_opam" + "esy.lock" + ]; + }; + openstack = { + format = "[$symbol$cloud(($project))]($style) "; + symbol = "☁️ "; + style = "bold yellow"; + disabled = false; + }; + package = { + format = "[$symbol$version]($style) "; + symbol = "📦 "; + style = "208 bold"; + display_private = false; + disabled = false; + version_format = "v$raw"; + }; + perl = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐪 "; + style = "149 bold"; + disabled = false; + detect_extensions = [ + "pl" + "pm" + "pod" + ]; + detect_files = [ + "Makefile.PL" + "Build.PL" + "cpanfile" + "cpanfile.snapshot" + "META.json" + "META.yml" + ".perl-version" + ]; + detect_folders = [ ]; + }; + php = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐘 "; + style = "147 bold"; + disabled = false; + detect_extensions = [ "php" ]; + detect_files = [ + "composer.json" + ".php-version" + ]; + detect_folders = [ ]; + }; + pulumi = { + format = "[$symbol($username@)$stack]($style) "; + version_format = "v$raw"; + symbol = " "; + style = "bold 5"; + disabled = false; + }; + purescript = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "<=> "; + style = "bold white"; + disabled = false; + detect_extensions = [ "purs" ]; + detect_files = [ "spago.dhall" ]; + detect_folders = [ ]; + }; + python = { + format = "[$symbol$pyenv_prefix($version )(($virtualenv) )]($style)"; + python_binary = [ + "python" + "python3" + "python2" + ]; + pyenv_prefix = "pyenv "; + pyenv_version_name = true; + style = "yellow bold"; + symbol = "🐍 "; + version_format = "v$raw"; + disabled = false; + detect_extensions = [ "py" ]; + detect_files = [ + "requirements.txt" + ".python-version" + "pyproject.toml" + "Pipfile" + "tox.ini" + "setup.py" + "__init__.py" + ]; + detect_folders = [ ]; + }; + red = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🔺 "; + style = "red bold"; + disabled = false; + detect_extensions = [ + "red" + "reds" + ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + rlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + style = "blue bold"; + symbol = "📐 "; + disabled = false; + detect_extensions = [ + "R" + "Rd" + "Rmd" + "Rproj" + "Rsx" + ]; + detect_files = [ ".Rprofile" ]; + detect_folders = [ ".Rproj.user" ]; + }; + ruby = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "💎 "; + style = "bold red"; + disabled = false; + detect_extensions = [ "rb" ]; + detect_files = [ + "Gemfile" + ".ruby-version" + ]; + detect_folders = [ ]; + detect_variables = [ + "RUBY_VERSION" + "RBENV_VERSION" + ]; + }; + rust = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🦀 "; + style = "bold red bg:0x86BBD8"; + disabled = false; + detect_extensions = [ "rs" ]; + detect_files = [ "Cargo.toml" ]; + detect_folders = [ ]; + }; + scala = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + disabled = false; + style = "red bold"; + symbol = "🆂 "; + detect_extensions = [ + "sbt" + "scala" + ]; + detect_files = [ + ".scalaenv" + ".sbtenv" + "build.sbt" + ]; + detect_folders = [ ".metals" ]; + }; + shell = { + format = "[$indicator]($style) "; + bash_indicator = "bsh"; + cmd_indicator = "cmd"; + elvish_indicator = "esh"; + fish_indicator = ""; + ion_indicator = "ion"; + nu_indicator = "nu"; + powershell_indicator = "_"; + style = "white bold"; + tcsh_indicator = "tsh"; + unknown_indicator = "mystery shell"; + xonsh_indicator = "xsh"; + zsh_indicator = "zsh"; + disabled = false; + }; + shlvl = { + threshold = 2; + format = "[$symbol$shlvl]($style) "; + symbol = "↕️ "; + repeat = false; + style = "bold yellow"; + disabled = true; + }; + singularity = { + format = "[$symbol[$env]]($style) "; + style = "blue bold dimmed"; + symbol = "📦 "; + disabled = false; + }; + spack = { + truncation_length = 1; + format = "[$symbol$environment]($style) "; + symbol = "🅢 "; + style = "blue bold"; + disabled = false; + }; + status = { + format = "[$symbol$status]($style) "; + map_symbol = true; + not_executable_symbol = "🚫"; + not_found_symbol = "🔍"; + pipestatus = false; + pipestatus_format = "[$pipestatus] => [$symbol$common_meaning$signal_name$maybe_int]($style)"; + pipestatus_separator = "|"; + recognize_signal_code = true; + signal_symbol = "⚡"; + style = "bold red bg:blue"; + success_symbol = "🟢 SUCCESS"; + symbol = "🔴 "; + disabled = true; + }; + sudo = { + format = "[as $symbol]($style)"; + symbol = "🧙 "; + style = "bold blue"; + allow_windows = false; + disabled = true; + }; + swift = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "🐦 "; + style = "bold 202"; + disabled = false; + detect_extensions = [ "swift" ]; + detect_files = [ "Package.swift" ]; + detect_folders = [ ]; + }; + terraform = { + format = "[$symbol$workspace]($style) "; + version_format = "v$raw"; + symbol = "💠 "; + style = "bold 105"; + disabled = false; + detect_extensions = [ + "tf" + "tfplan" + "tfstate" + ]; + detect_files = [ ]; + detect_folders = [ ".terraform" ]; + }; + time = { + format = "[$symbol $time]($style) "; + style = "bold yellow bg:0x33658A"; + use_12hr = false; + disabled = false; + utc_time_offset = "local"; + # time_format = "%R"; # Hour:Minute Format; + time_format = "%T"; # Hour:Minute:Seconds Format; + time_range = "-"; + }; + username = { + format = "[$user]($style) "; + show_always = true; + style_root = "red bold bg:0x9A348E"; + style_user = "yellow bold bg:0x9A348E"; + disabled = false; + }; + vagrant = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "⍱ "; + style = "cyan bold"; + disabled = false; + detect_extensions = [ ]; + detect_files = [ "Vagrantfile" ]; + detect_folders = [ ]; + }; + vcsh = { + symbol = ""; + style = "bold yellow"; + format = "[$symbol$repo]($style) "; + disabled = false; + }; + vlang = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "V "; + style = "blue bold"; + disabled = false; + detect_extensions = [ "v" ]; + detect_files = [ + "v.mod" + "vpkg.json" + ".vpkg-lock.json" + ]; + detect_folders = [ ]; + }; + zig = { + format = "[$symbol($version )]($style)"; + version_format = "v$raw"; + symbol = "↯ "; + style = "bold yellow"; + disabled = false; + detect_extensions = [ "zig" ]; + detect_files = [ ]; + detect_folders = [ ]; + }; + custom = { }; }; + }; # https://nix-community.github.io/home-manager/options.html#opt-programs.direnv.config programs.direnv = { diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 6eb1100..96c7238 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -1,52 +1,53 @@ - { - description = "Home Manager configuration"; +{ + description = "Home Manager configuration"; - inputs = { - # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; + inputs = { + # Specify the source of Home Manager and Nixpkgs + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; - outputs = { nixpkgs, home-manager, ... }: - let - system = "x86_64-linux"; - username = "1M0b4nc0"; - hostname = "fooo"; + outputs = { nixpkgs, home-manager, ... }: + let + system = "x86_64-linux"; + username = "1M0b4nc0"; + hostname = "fooo"; + pkgs = nixpkgs.legacyPackages.${system}; + in + { + homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; - in { - homeConfigurations."${username}-${hostname}" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; - - modules = [ - { - home = { - inherit username; - homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! - stateVersion = "22.11"; - }; - programs.home-manager.enable = true; - } - ./home.nix - ]; - # TODO: how to: Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; + modules = [ + { + home = { + inherit username; + homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! + stateVersion = "22.11"; + }; + programs.home-manager.enable = true; + } + ./home.nix + ]; - devShells.x86_64-linux.default = pkgs.mkShell { - buildInputs = with pkgs; [ - bashInteractive - coreutils - curl - gnumake - patchelf - poetry - python3Full - tmate - ]; - }; + # TODO: how to: Optionally use extraSpecialArgs + # to pass through arguments to home.nix + }; + devShells.x86_64-linux.default = pkgs.mkShell { + buildInputs = with pkgs; [ + bashInteractive + coreutils + curl + gnumake + patchelf + poetry + python3Full + tmate + ]; }; - } + + }; +} diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index bf1ef43..9bd34d5 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -36,31 +36,31 @@ tree killall btop -# nmap -# netcat -# nettools + # nmap + # netcat + # nettools tmate strace # ptrace -# traceroute + # traceroute man man-db -# (aspellWithDicts (d: with d; [ de en pt_BR ])) # nix repl --expr 'import {}' <<<'builtins.attrNames aspellDicts' | tr ' ' '\n' -# nix-prefetch-git -# nixfmt -# hydra-check -# nixos-option -# shellcheck - nano - vim + # (aspellWithDicts (d: with d; [ de en pt_BR ])) # nix repl --expr 'import {}' <<<'builtins.attrNames aspellDicts' | tr ' ' '\n' + # nix-prefetch-git + # nixfmt + # hydra-check + # nixos-option + # shellcheck + nano + vim # fontconfig # fontforge-gtk # TODO: testar fontes usando esse programa # pango -# nerdfonts -# powerline -# powerline-fonts + # nerdfonts + # powerline + # powerline-fonts # (nerdfonts.override { fonts = [ "FiraCode"]; }) @@ -95,195 +95,195 @@ # python3Full # julia-bin -# graphviz # dot command comes from here + # graphviz # dot command comes from here jq -# unixtools.xxd - -# gzip -# # unrar -# unzip -# gnutar -# -# btop -# htop -# asciinema + # unixtools.xxd + + # gzip + # # unrar + # unzip + # gnutar + # + # btop + # htop + # asciinema git openssh awscli podman - ( - writeScriptBin "ix" '' - #! ${pkgs.runtimeShell} -e - "$@" | "curl" -F 'f:1=<-' ix.io - '' - ) - - ( - writeScriptBin "erw" '' - #! ${pkgs.runtimeShell} -e - echo "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "frw" '' - #! ${pkgs.runtimeShell} -e - file "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "crw" '' - #! ${pkgs.runtimeShell} -e - cat "$(readlink -f "$(which $1)")" - '' - ) - - ( - writeScriptBin "send-signed-closure-run-time-of-flake-uri-attr-to-bucket" '' - #! ${pkgs.runtimeShell} -e - - export NIXPKGS_ALLOW_UNFREE=1 - FLAKE_EXPR=$1 - - nix build --no-link --print-build-logs "$FLAKE_EXPR" - - nix path-info --impure --recursive "$FLAKE_EXPR" \ - | wc -l - - nix path-info --impure --recursive "$FLAKE_EXPR" \ - | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive - - nix path-info --impure --recursive "$FLAKE_EXPR" \ - | xargs -I{} nix \ - copy \ - --max-jobs $(nproc) \ - -vvv \ - --no-check-sigs \ - {} \ - --to 's3://playing-bucket-nix-cache-test' - '' - ) - - ( - writeScriptBin "send-signed-closure-run-time-of-flake-expression-to-bucket" '' - #! ${pkgs.runtimeShell} -e - - export NIXPKGS_ALLOW_UNFREE=1 - FLAKE_EXPR=$1 - - nix build --no-link --print-build-logs --expr "$FLAKE_EXPR" - - nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ - | wc -l - - nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ - | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive - - nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ - | xargs -I{} nix \ - copy \ - --max-jobs $(nproc) \ - -vvv \ - --no-check-sigs \ - {} \ - --to 's3://playing-bucket-nix-cache-test' - '' - ) - - ( - writeScriptBin "self-send-to-bucket" '' - #! ${pkgs.runtimeShell} -e - send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ - ~/.config/nixpkgs#homeConfigurations.'"'"$(id -un)"-"$(hostname)"'"'.activationPackage - '' - ) - - ( - writeScriptBin "myexternalip" '' - #! ${pkgs.runtimeShell} -e - # https://askubuntu.com/questions/95910/command-for-determining-my-public-ip#comment1985064_712144 - - curl https://checkip.amazonaws.com - '' - ) - - ( - writeScriptBin "mynatip" '' - #! ${pkgs.runtimeShell} -e - # https://unix.stackexchange.com/a/569306 - # https://serverfault.com/a/256506 - - NETWORK_INTERFACE_NAME=$(route | awk ' - BEGIN { min = -1 } - $1 == "default" { - if (min < 0 || $5 < min) { - min = $5 - iface = $8 - } - } - END { - if (iface == "") { - print "No \"default\" route found!" > "/dev/stderr" - exit 1 - } else { - print iface - exit 0 - } - } - ' - ) - - ip addr show dev $NETWORK_INTERFACE_NAME | grep "inet " | awk '{ print $2 }' | cut -d'/' -f1 - '' - ) - - ( - writeScriptBin "generate-new-ed25519-key-pair" '' - #! ${pkgs.runtimeShell} -e - ssh-keygen \ - -t ed25519 \ - -C "$(git config user.email)" \ - -f "$HOME"/.ssh/id_ed25519 \ - -N "" \ - && echo \ - && cat "$HOME"/.ssh/id_ed25519.pub \ - && echo - '' - ) - - ( - writeScriptBin "try-install-openssh-server" '' - #! ${pkgs.runtimeShell} -e - command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) - command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) - '' - ) - - ( - writeScriptBin "try-ubuntu-screensaver-lock-disable" '' - #! ${pkgs.runtimeShell} -e - # https://linuxhint.com/disable-screen-lock-ubuntu/ - - gsettings set org.gnome.desktop.screensaver lock-enabled false - '' - ) - - ( - writeScriptBin "try-ubuntu-screensaver-lock-enable" '' - #! ${pkgs.runtimeShell} -e - gsettings set org.gnome.desktop.screensaver lock-enabled true - '' - ) - - ( - writeScriptBin "nfm" '' - #! ${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) + ( + writeScriptBin "ix" '' + #! ${pkgs.runtimeShell} -e + "$@" | "curl" -F 'f:1=<-' ix.io + '' + ) + + ( + writeScriptBin "erw" '' + #! ${pkgs.runtimeShell} -e + echo "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "frw" '' + #! ${pkgs.runtimeShell} -e + file "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "crw" '' + #! ${pkgs.runtimeShell} -e + cat "$(readlink -f "$(which $1)")" + '' + ) + + ( + writeScriptBin "send-signed-closure-run-time-of-flake-uri-attr-to-bucket" '' + #! ${pkgs.runtimeShell} -e + + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 + + nix build --no-link --print-build-logs "$FLAKE_EXPR" + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | wc -l + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) + + ( + writeScriptBin "send-signed-closure-run-time-of-flake-expression-to-bucket" '' + #! ${pkgs.runtimeShell} -e + + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 + + nix build --no-link --print-build-logs --expr "$FLAKE_EXPR" + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | wc -l + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) + + ( + writeScriptBin "self-send-to-bucket" '' + #! ${pkgs.runtimeShell} -e + send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ + ~/.config/nixpkgs#homeConfigurations.'"'"$(id -un)"-"$(hostname)"'"'.activationPackage + '' + ) + + ( + writeScriptBin "myexternalip" '' + #! ${pkgs.runtimeShell} -e + # https://askubuntu.com/questions/95910/command-for-determining-my-public-ip#comment1985064_712144 + + curl https://checkip.amazonaws.com + '' + ) + + ( + writeScriptBin "mynatip" '' + #! ${pkgs.runtimeShell} -e + # https://unix.stackexchange.com/a/569306 + # https://serverfault.com/a/256506 + + NETWORK_INTERFACE_NAME=$(route | awk ' + BEGIN { min = -1 } + $1 == "default" { + if (min < 0 || $5 < min) { + min = $5 + iface = $8 + } + } + END { + if (iface == "") { + print "No \"default\" route found!" > "/dev/stderr" + exit 1 + } else { + print iface + exit 0 + } + } + ' + ) + + ip addr show dev $NETWORK_INTERFACE_NAME | grep "inet " | awk '{ print $2 }' | cut -d'/' -f1 + '' + ) + + ( + writeScriptBin "generate-new-ed25519-key-pair" '' + #! ${pkgs.runtimeShell} -e + ssh-keygen \ + -t ed25519 \ + -C "$(git config user.email)" \ + -f "$HOME"/.ssh/id_ed25519 \ + -N "" \ + && echo \ + && cat "$HOME"/.ssh/id_ed25519.pub \ + && echo + '' + ) + + ( + writeScriptBin "try-install-openssh-server" '' + #! ${pkgs.runtimeShell} -e + command -v sshd || (command -v apt && sudo apt-get update && sudo apt-get install -y openssh-server) + command -v sshd || (command -v apk && sudo apk add --no-cache -y openssh-server) + '' + ) + + ( + writeScriptBin "try-ubuntu-screensaver-lock-disable" '' + #! ${pkgs.runtimeShell} -e + # https://linuxhint.com/disable-screen-lock-ubuntu/ + + gsettings set org.gnome.desktop.screensaver lock-enabled false + '' + ) + + ( + writeScriptBin "try-ubuntu-screensaver-lock-enable" '' + #! ${pkgs.runtimeShell} -e + gsettings set org.gnome.desktop.screensaver lock-enabled true + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) ( writeScriptBin "hms" '' @@ -300,48 +300,48 @@ '' ) - ( - writeScriptBin "build-pulling-all-from-cache" '' - #! ${pkgs.runtimeShell} -e - - set -x - - export NIXPKGS_ALLOW_UNFREE=1 - - nix \ - --option eval-cache false \ - --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ - --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - build \ - --impure \ - --keep-failed \ - --max-jobs 0 \ - --no-link \ - --print-build-logs \ - --print-out-paths \ - ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage - '' - ) - - ( - writeScriptBin "build-and-send-to-cache" '' - #! ${pkgs.runtimeShell} -e - - set -x - - export NIXPKGS_ALLOW_UNFREE=1 - - nix \ - build \ - --impure \ - --keep-failed \ - --no-link \ - --print-build-logs \ - --print-out-paths \ - ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage \ - --post-build-hook e-script-post-build-hook - '' - ) + ( + writeScriptBin "build-pulling-all-from-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + export NIXPKGS_ALLOW_UNFREE=1 + + nix \ + --option eval-cache false \ + --option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ + --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ + build \ + --impure \ + --keep-failed \ + --max-jobs 0 \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage + '' + ) + + ( + writeScriptBin "build-and-send-to-cache" '' + #! ${pkgs.runtimeShell} -e + + set -x + + export NIXPKGS_ALLOW_UNFREE=1 + + nix \ + build \ + --impure \ + --keep-failed \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + ~/.config/nixpkgs#homeConfigurations."$(id -un)"-"$(hostname)".activationPackage \ + --post-build-hook e-script-post-build-hook + '' + ) ( writeScriptBin "gphms-cache" '' @@ -374,57 +374,57 @@ '' ) - ( - writeScriptBin "send-signed-closure-run-time-of-flake-uri-attr-to-bucket" '' - #! ${pkgs.runtimeShell} -e + ( + writeScriptBin "send-signed-closure-run-time-of-flake-uri-attr-to-bucket" '' + #! ${pkgs.runtimeShell} -e - export NIXPKGS_ALLOW_UNFREE=1 - FLAKE_EXPR=$1 + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 - nix build --no-link --print-build-logs "$FLAKE_EXPR" + nix build --no-link --print-build-logs "$FLAKE_EXPR" - nix path-info --impure --recursive "$FLAKE_EXPR" \ - | wc -l + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | wc -l - nix path-info --impure --recursive "$FLAKE_EXPR" \ - | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive - nix path-info --impure --recursive "$FLAKE_EXPR" \ - | xargs -I{} nix \ - copy \ - --max-jobs $(nproc) \ - -vvv \ - --no-check-sigs \ - {} \ - --to 's3://playing-bucket-nix-cache-test' - '' - ) + nix path-info --impure --recursive "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) - ( - writeScriptBin "send-signed-closure-run-time-of-flake-expression-to-bucket" '' - #! ${pkgs.runtimeShell} -e + ( + writeScriptBin "send-signed-closure-run-time-of-flake-expression-to-bucket" '' + #! ${pkgs.runtimeShell} -e - export NIXPKGS_ALLOW_UNFREE=1 - FLAKE_EXPR=$1 + export NIXPKGS_ALLOW_UNFREE=1 + FLAKE_EXPR=$1 - nix build --no-link --print-build-logs --expr "$FLAKE_EXPR" + nix build --no-link --print-build-logs --expr "$FLAKE_EXPR" - nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ - | wc -l + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | wc -l - nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ - | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs nix store sign --key-file "$HOME"/.nix-sing-cache-keys/cache-priv-key.pem --recursive - nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ - | xargs -I{} nix \ - copy \ - --max-jobs $(nproc) \ - -vvv \ - --no-check-sigs \ - {} \ - --to 's3://playing-bucket-nix-cache-test' - '' - ) + nix path-info --impure --recursive --expr "$FLAKE_EXPR" \ + | xargs -I{} nix \ + copy \ + --max-jobs $(nproc) \ + -vvv \ + --no-check-sigs \ + {} \ + --to 's3://playing-bucket-nix-cache-test' + '' + ) ( writeScriptBin "nr" '' @@ -672,10 +672,10 @@ }; }; - programs.starship = { - enable = true; - enableZshIntegration = true; - }; + programs.starship = { + enable = true; + enableZshIntegration = true; + }; # https://nix-community.github.io/home-manager/options.html#opt-programs.direnv.config programs.direnv = { From 7011b1012cb7360c8698a29c20259f9019c2a915 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 7 May 2023 02:16:24 -0300 Subject: [PATCH 095/191] WIP --- profile/README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/profile/README.md b/profile/README.md index dcf91df..45d9318 100644 --- a/profile/README.md +++ b/profile/README.md @@ -13,15 +13,20 @@ wget -qO- http://ix.io/4tTQ | sh \ && . "$HOME"/."$(basename $SHELL)"rc \ && nix flake --version ``` +4vmd + Versão longa: ```bash command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) command -v curl || (command -v apk && sudo apk add --no-cache curl) +# DAEMON_OR_NO_DAEMON='--'"$((lauchctl --version 1>/dev/null 2>/dev/null || systemctl --version 1>/dev/null 2>/dev/null) && echo daemon || echo no-daemon)" +DAEMON_OR_NO_DAEMON='--'"$($(lauchctl --version 1>/dev/null 2>/dev/null) && echo daemon || echo no-daemon)" + NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- --no-daemon \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- "$DAEMON_OR_NO_DAEMON" \ && . "$HOME"/.nix-profile/etc/profile.d/nix.sh NAME_SHELL=$(basename $SHELL) \ @@ -41,7 +46,7 @@ NAME_SHELL=$(basename $SHELL) \ Crie um arquivo e copie e cole o bloco de código acima no arquivo. ```bash -vi arquivo.txt +nano arquivo.txt ``` Após salvar: @@ -715,7 +720,7 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +.#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` ```bash @@ -725,10 +730,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -745,7 +750,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -795,7 +800,7 @@ ssh-add id_ed25519 nix \ run \ -github:PedroRegisPOAR/.github/6687778e4f350b968804a3f019248794409e979d#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ +github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & From dedbc916d93e222169779defef4db16bb86dc7ed Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 7 May 2023 12:14:51 -0300 Subject: [PATCH 096/191] Aumenta o command_timeout --- templates/start-slim-config/home.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 9bd34d5..759c42b 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -675,6 +675,11 @@ programs.starship = { enable = true; enableZshIntegration = true; + settings = { + # "$schema" = "https://starship.rs/config-schema.json"; + # add_newline = true; + command_timeout = 50000; # TODO: qual a unidade? + }; }; # https://nix-community.github.io/home-manager/options.html#opt-programs.direnv.config From ead2cfa1e48c15493f9158aa20933c90130d8a79 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 00:36:42 -0300 Subject: [PATCH 097/191] =?UTF-8?q?Adiciona=20.envrc=20neste=20pr=C3=B3pri?= =?UTF-8?q?o=20reposit=C3=B3rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .envrc | 1 + profile/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/profile/README.md b/profile/README.md index 45d9318..c3e2e35 100644 --- a/profile/README.md +++ b/profile/README.md @@ -839,7 +839,7 @@ ssh \ ssh://nixuser@localhost:10022 \ -o StreamLocalBindUnlink=yes -export CONTAINER_HOST=unix://tmp/podman.sock +export CONTAINER_HOST=unix:///tmp/podman.sock podman run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' ``` From 3523b9a1c8beef19a5ebd7e4dd6fe9b34b78b469 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 00:37:55 -0300 Subject: [PATCH 098/191] Adiciona .direnv/ no .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4d44c68..ef840a1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ result __pycache__/ *.tar.gz + +.direnv/ From a89c7f6a2017cc17e176db10d21e9eb14b3d9f97 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 11:06:24 -0300 Subject: [PATCH 099/191] WIP, e
--- profile/README.md | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/profile/README.md b/profile/README.md index c3e2e35..5fc18b5 100644 --- a/profile/README.md +++ b/profile/README.md @@ -15,8 +15,9 @@ wget -qO- http://ix.io/4tTQ | sh \ ``` 4vmd +
+ Versão longa (click para expandir): -Versão longa: ```bash command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) command -v curl || (command -v apk && sudo apk add --no-cache curl) @@ -53,7 +54,7 @@ Após salvar: ```bash cat arquivo.txt | curl -F 'f:1=<-' ix.io ``` - +
Existem 3 tipos de configurações, descritos nas próximas seções: apenas CLI, apenas CLI slim, e com programas com interface gráfica. @@ -785,18 +786,18 @@ chmod -v 0600 id_ed25519 # Oh crap, it made me wast many many days ssh-add id_ed25519 -#nix \ -#--option eval-cache false \ -#--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ -#--option extra-substituters "s3://playing-bucket-nix-cache-test" \ -#build \ -#--keep-failed \ -#--max-jobs 0 \ -#--no-link \ -#--no-show-trace \ -#--print-build-logs \ -#--print-out-paths \ -#github:PedroRegisPOAR/.github/fe92d991ab7f32a6d3589a33a1b473d5f61fa9c9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +build \ +--keep-failed \ +--max-jobs 0 \ +--no-link \ +--no-show-trace \ +--print-build-logs \ +--print-out-paths \ +github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm nix \ run \ @@ -804,7 +805,7 @@ github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConf < /dev/null & -while ! ssh -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'nix flake metadata nixpkgs'; do \ +while ! ssh -T -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done \ && ssh-keygen -R '[localhost]:'"$HOST_MAPPED_PORT"; \ ssh \ From a9a1cdd4a986a5fb28b228ec324adcbf6f4af8e0 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 11:20:19 -0300 Subject: [PATCH 100/191] WIP --- profile/README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/profile/README.md b/profile/README.md index 5fc18b5..32f52ed 100644 --- a/profile/README.md +++ b/profile/README.md @@ -5,15 +5,15 @@ ## Template -1) +1) Instalação do nix single user. Versão curta: ```bash -wget -qO- http://ix.io/4tTQ | sh \ +wget -qO- http://ix.io/4vmd | sh \ && . "$HOME"/."$(basename $SHELL)"rc \ && nix flake --version ``` -4vmd +
Versão longa (click para expandir): @@ -45,7 +45,7 @@ NAME_SHELL=$(basename $SHELL) \ && . "$HOME"/.profile ``` -Crie um arquivo e copie e cole o bloco de código acima no arquivo. +Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. ```bash nano arquivo.txt ``` @@ -54,8 +54,13 @@ Após salvar: ```bash cat arquivo.txt | curl -F 'f:1=<-' ix.io ``` + +Basta atualizar a versão curta da instalação. +
+## Parte 2, home-manager + nix + Existem 3 tipos de configurações, descritos nas próximas seções: apenas CLI, apenas CLI slim, e com programas com interface gráfica. @@ -599,19 +604,24 @@ https://github.com/imobanco/.config-nixpkgs ### Mac +#### Instalando o homebrew ```bash NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/fc8acb0828f89f8aa83162000db1b49de71fa5d8/install.sh)" \ && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME"/.zprofile ``` - - +Instalando o `hello`: ```bash brew install hello ``` +Testando o `hello` +```bash +hello +``` +Desistalando o `hello`: ```bash brew uninstall hello ``` @@ -624,7 +634,7 @@ NIX_RELEASE_VERSION=2.10.2 \ && echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile ``` -Feche o terminal. +Feche o terminal, instalador obriga. Abra o terminal: ```bash @@ -1105,4 +1115,3 @@ PID=? tr '\0' '\n' < /proc/${PID}/cmdline strace -f -T -y -e trace=file ``` - From c5ff24579ff2dfe933e517660ab218e8bacfe9e1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 11:36:12 -0300 Subject: [PATCH 101/191] =?UTF-8?q?Testa=20aumentar=20tamanho=20do=20disco?= =?UTF-8?q?=20da=20m=C3=A1quina=20virtual?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 9834452..a861431 100644 --- a/flake.nix +++ b/flake.nix @@ -139,7 +139,9 @@ virtualisation = { # following configuration is added only when building VM with build-vm memorySize = 3072; # Use MiB memory. - diskSize = 4096; # Use MiB memory. + + # nixos-disk-image> ERROR: cptofs failed. diskSize might be too small for closure. + diskSize = 15*1024; # Use MiB memory. cores = 7; # Simulate 3 cores. # podman.enable = true; From f7e29b0eb02fb6a00f96e8a171bebf9c52f47562 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 18:58:33 -0300 Subject: [PATCH 102/191] Testa build-vm no shellHook --- flake.nix | 28 +++++++++++++++++++++++++++- id_ed25519 | 7 +++++++ profile/README.md | 36 +++++++++++++++++++++++++++++------- 3 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 id_ed25519 diff --git a/flake.nix b/flake.nix index a861431..2d9d6e7 100644 --- a/flake.nix +++ b/flake.nix @@ -596,7 +596,33 @@ ]; shellHook = '' - echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat + echo -e 'IMO \n Banco' | "${pkgsAllowUnfree.figlet}/bin/figlet" | cat + + export NIXOS_VM_USER=nixuser + export HOST_MAPPED_PORT=10022 + export REMOVE_DISK=true + export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 + # export QEMU_OPTS=-nographic + export QEMU_OPTS="-daemonize -display none -monitor none" + export SHARED_DIR="$(pwd)" + export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm + export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock + + "$REMOVE_DISK" && rm -fv nixos.qcow2 + + # chmod 0600 .id_ed25519 + IDENTITY_FULL_PATH=./id_ed25519 + + ssh-keygen -R '[localhost]:10022' + ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add ./ops/nix/id_ed25519 + + ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ + || $("$RUN_BUID_VM_SCRIPT_PATH" &) + + # TODO: pq o podman.service não está ativo? + while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ + echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done + ''; }; }); diff --git a/id_ed25519 b/id_ed25519 new file mode 100644 index 0000000..99d6c3b --- /dev/null +++ b/id_ed25519 @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5JcgAAAIjoIwah6CMG +oQAAAAtzc2gtZWQyNTUxOQAAACCsoS8eR1Ot8ySeS8eI/jUwvzkGe1npaHPMvjp+Ou5Jcg +AAAEAbL0Z61S8giktfR53dZ2fztctV/0vML24doU0BMGLRZqyhLx5HU63zJJ5Lx4j+NTC/ +OQZ7Weloc8y+On467klyAAAAAAECAwQF +-----END OPENSSH PRIVATE KEY----- diff --git a/profile/README.md b/profile/README.md index 32f52ed..d7614f0 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1,6 +1,10 @@ # Hi there 👋 - +```bash +git clone git@github.com:PedroRegisPOAR/.github.git \ +&& cd .github \ +&& ((direnv 1>/dev/null 2>/dev/null && direnv allow) || nix develop .#) +``` ## Template @@ -741,10 +745,10 @@ build \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ -github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -761,7 +765,7 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` @@ -793,6 +797,9 @@ EOF chmod -v 0600 id_ed25519 + + +ssh-keygen -R '[localhost]:10022' # Oh crap, it made me wast many many days ssh-add id_ed25519 @@ -807,11 +814,11 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/25b63fda6625c68d3b6ad206c45d516f0a7efda5#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ +github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & @@ -830,6 +837,9 @@ nixuser@localhost \ #COMMANDS #"$REMOVE_DISK" && rm -fv nixos.qcow2 id_ed25519 ``` +Refs.: +- https://stackoverflow.com/questions/20840012/ssh-remote-host-identification-has-changed#comment89964721_23150466 + ```bash export CONTAINER_HOST=ssh://nixuser@localhost:10022/run/user/1234/podman/podman.sock @@ -840,6 +850,18 @@ Refs.: - +```bash +# make down +ssh \ +-T \ +-i id_ed25519 \ +-X \ +-o StrictHostKeyChecking=no \ +root@localhost \ +-p "$HOST_MAPPED_PORT" \ +<<<'shutdown now' +``` + Broken: ```bash @@ -868,7 +890,7 @@ Refs.: ##### podman system connection add ```bash -export DOCKER_HOST = "ssh://root@podman-romote-host" +export DOCKER_HOST="ssh://root@podman-romote-host" podman system connection add --identity ~/.ssh/id_rsa production $DOCKER_HOST podman run hello-world ``` From d2f668e0e7846b117c700a40107aef7be5384cea Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:02:43 -0300 Subject: [PATCH 103/191] Usa apenas -nographic --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 2d9d6e7..8253ea6 100644 --- a/flake.nix +++ b/flake.nix @@ -602,8 +602,8 @@ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 - # export QEMU_OPTS=-nographic - export QEMU_OPTS="-daemonize -display none -monitor none" + export QEMU_OPTS="-nographic" + # export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock From 233195fd5bd5db770570c690e01a02542882e321 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:09:36 -0300 Subject: [PATCH 104/191] Testa < /dev/null & --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8253ea6..866440b 100644 --- a/flake.nix +++ b/flake.nix @@ -617,7 +617,7 @@ ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add ./ops/nix/id_ed25519 ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || $("$RUN_BUID_VM_SCRIPT_PATH" &) + || "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From a296a7dfb6a52f194bb7602bb5a9d2729e1620b3 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:13:12 -0300 Subject: [PATCH 105/191] Remove hardcoded e adiciona $() --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 866440b..0ccf290 100644 --- a/flake.nix +++ b/flake.nix @@ -614,10 +614,10 @@ IDENTITY_FULL_PATH=./id_ed25519 ssh-keygen -R '[localhost]:10022' - ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add ./ops/nix/id_ed25519 + ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & + || $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From bbcb1c858210d78e3fd08e423fbc11fa2bab05f3 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:14:22 -0300 Subject: [PATCH 106/191] Adiciona & --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 0ccf290..d3bcfbd 100644 --- a/flake.nix +++ b/flake.nix @@ -617,7 +617,7 @@ ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) + || $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From d0ef690f74de5bd43e08880ae11b05514fa43014 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:16:04 -0300 Subject: [PATCH 107/191] Adiciona debug --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index d3bcfbd..00e1e13 100644 --- a/flake.nix +++ b/flake.nix @@ -623,6 +623,8 @@ while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done + echo $SHELL + ''; }; }); From 024b85b726b2bd346675f709a54c1655799436c1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:17:53 -0300 Subject: [PATCH 108/191] Adiciona debug --- flake.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 00e1e13..dd86311 100644 --- a/flake.nix +++ b/flake.nix @@ -616,15 +616,13 @@ ssh-keygen -R '[localhost]:10022' ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" - ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) & + $( ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ + || "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done - echo $SHELL - ''; }; }); From 1374927520772687bc0b08469919cfae38314ef1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:21:49 -0300 Subject: [PATCH 109/191] Remove < /dev/null --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index dd86311..6a5b9a2 100644 --- a/flake.nix +++ b/flake.nix @@ -617,7 +617,7 @@ ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" $( ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) & + || "$RUN_BUID_VM_SCRIPT_PATH" &) & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 58b59295e367d2ed3467d4e517ece673e07815bf Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:23:07 -0300 Subject: [PATCH 110/191] =?UTF-8?q?Testa=20simplifica=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 6a5b9a2..7df5c3a 100644 --- a/flake.nix +++ b/flake.nix @@ -602,8 +602,8 @@ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 - export QEMU_OPTS="-nographic" - # export QEMU_OPTS="-daemonize -display none -monitor none" + # export QEMU_OPTS="-nographic" + export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock @@ -616,8 +616,8 @@ ssh-keygen -R '[localhost]:10022' ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" - $( ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || "$RUN_BUID_VM_SCRIPT_PATH" &) & + ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ + || "$RUN_BUID_VM_SCRIPT_PATH" # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 579a8d463c6130b6a1a15ebcca362d2df00baea2 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:32:24 -0300 Subject: [PATCH 111/191] =?UTF-8?q?Testa=20outra=20combina=C3=A7=C3=A3o,?= =?UTF-8?q?=20from=20SO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 7df5c3a..7a35a90 100644 --- a/flake.nix +++ b/flake.nix @@ -602,8 +602,8 @@ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 - # export QEMU_OPTS="-nographic" - export QEMU_OPTS="-daemonize -display none -monitor none" + export QEMU_OPTS="-nographic" + # export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock @@ -617,7 +617,7 @@ ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || "$RUN_BUID_VM_SCRIPT_PATH" + || ( "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 6dfce9303732eae6cd579331d97f81b2e84120cc Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:33:50 -0300 Subject: [PATCH 112/191] =?UTF-8?q?Testa=20outra=20combina=C3=A7=C3=A3o,?= =?UTF-8?q?=20from=20SO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 7a35a90..b2ed39e 100644 --- a/flake.nix +++ b/flake.nix @@ -617,7 +617,7 @@ ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || ( "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) + || ( "$RUN_BUID_VM_SCRIPT_PATH" &) # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 811e5d3a889dba80e9a14f0ce812b08b0f02472c Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:40:58 -0300 Subject: [PATCH 113/191] =?UTF-8?q?Testa=20simplifica=C3=A7=C3=A3o=20apena?= =?UTF-8?q?s=20build-vm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index b2ed39e..8b03ed0 100644 --- a/flake.nix +++ b/flake.nix @@ -616,8 +616,10 @@ ssh-keygen -R '[localhost]:10022' ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" - ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ - || ( "$RUN_BUID_VM_SCRIPT_PATH" &) + # ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ + # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) + + "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From ebc6b717a9aaa49546e1e17e424a8913dabea9e3 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:42:19 -0300 Subject: [PATCH 114/191] Muda QEMU_NET_OPTS --- flake.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 8b03ed0..a3b307c 100644 --- a/flake.nix +++ b/flake.nix @@ -602,8 +602,8 @@ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 - export QEMU_OPTS="-nographic" - # export QEMU_OPTS="-daemonize -display none -monitor none" + # export QEMU_OPTS="-nographic" + export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock @@ -619,7 +619,8 @@ # ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) - "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & + # "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & + "$RUN_BUID_VM_SCRIPT_PATH" # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From e5cc8e0503c2c49d0e9064e11b25a85fcdde71a1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:48:50 -0300 Subject: [PATCH 115/191] Adds & --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index a3b307c..83db1f5 100644 --- a/flake.nix +++ b/flake.nix @@ -620,7 +620,7 @@ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) # "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & - "$RUN_BUID_VM_SCRIPT_PATH" + "$RUN_BUID_VM_SCRIPT_PATH" & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 032c13e1ab02d1219e5f4b41d8e474b880bb28a6 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 19:50:32 -0300 Subject: [PATCH 116/191] Mais testes --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 83db1f5..1fb86a7 100644 --- a/flake.nix +++ b/flake.nix @@ -602,8 +602,8 @@ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 - # export QEMU_OPTS="-nographic" - export QEMU_OPTS="-daemonize -display none -monitor none" + export QEMU_OPTS="-nographic" + # export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock @@ -620,7 +620,7 @@ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) # "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & - "$RUN_BUID_VM_SCRIPT_PATH" & + "$RUN_BUID_VM_SCRIPT_PATH" # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 2eb4fff10d6f3a3aaec8fb4a129d56896062cf5f Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 21:06:20 -0300 Subject: [PATCH 117/191] Testa virtualisation.graphics = false; --- flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flake.nix b/flake.nix index 1fb86a7..ecc24e9 100644 --- a/flake.nix +++ b/flake.nix @@ -149,6 +149,9 @@ # useNixStoreImage = true; writableStore = true; # TODO + + graphics = false; + # qemu.options = [ "-serial mon:stdio" ]; }; security.polkit.enable = true; From cbc7391181c7dad85c4f6c446b0131f89ee0418f Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 21:07:15 -0300 Subject: [PATCH 118/191] =?UTF-8?q?For=C3=A7a=20chmod=200600?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index ecc24e9..0fbc5e4 100644 --- a/flake.nix +++ b/flake.nix @@ -616,6 +616,8 @@ # chmod 0600 .id_ed25519 IDENTITY_FULL_PATH=./id_ed25519 + chmod -v 0600 "$IDENTITY_FULL_PATH" + ssh-keygen -R '[localhost]:10022' ssh-add -l | grep -q 'SHA256:NzLgwADMD4taCNCdiTTRz0yyMdN0AguJVZD+eHiQZjE' || ssh-add "$IDENTITY_FULL_PATH" From be03d87691d215cc711c104232d2e812c5f54a26 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 21:12:04 -0300 Subject: [PATCH 119/191] Testa & --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 0fbc5e4..e8741fe 100644 --- a/flake.nix +++ b/flake.nix @@ -150,6 +150,7 @@ useNixStoreImage = true; writableStore = true; # TODO + # https://github.com/nix-community/nixos-generators/blob/10079333313ff62446e6f2b0e7c5231c7431d269/formats/vm-nogui.nix#L17C1-L18 graphics = false; # qemu.options = [ "-serial mon:stdio" ]; }; @@ -625,7 +626,7 @@ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) # "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & - "$RUN_BUID_VM_SCRIPT_PATH" + "$RUN_BUID_VM_SCRIPT_PATH" & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 36f13c5fdd3c129354b65b57f3ae459d54a16ca6 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 21:32:01 -0300 Subject: [PATCH 120/191] Testa < /dev/null & --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index e8741fe..59e2a47 100644 --- a/flake.nix +++ b/flake.nix @@ -625,8 +625,8 @@ # ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) - # "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & - "$RUN_BUID_VM_SCRIPT_PATH" & + "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & + # "$RUN_BUID_VM_SCRIPT_PATH" & # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 7c60ffdbc3aed6885c0cf81eaec89bee069f0acb Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 21:33:11 -0300 Subject: [PATCH 121/191] Testa < /dev/null & + QEMU_OPTS --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 59e2a47..33d03a7 100644 --- a/flake.nix +++ b/flake.nix @@ -606,8 +606,8 @@ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 - export QEMU_OPTS="-nographic" - # export QEMU_OPTS="-daemonize -display none -monitor none" + # export QEMU_OPTS="-nographic" + export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock From 5abbd3f6c5163612b020cd8f3633126d38e76812 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 21:35:24 -0300 Subject: [PATCH 122/191] Testa qemu.options = [ "-serial mon:stdio" ]; --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 33d03a7..15b1b76 100644 --- a/flake.nix +++ b/flake.nix @@ -152,7 +152,7 @@ # https://github.com/nix-community/nixos-generators/blob/10079333313ff62446e6f2b0e7c5231c7431d269/formats/vm-nogui.nix#L17C1-L18 graphics = false; - # qemu.options = [ "-serial mon:stdio" ]; + qemu.options = [ "-serial mon:stdio" ]; }; security.polkit.enable = true; @@ -607,7 +607,7 @@ export REMOVE_DISK=true export QEMU_NET_OPTS=hostfwd=tcp::"$HOST_MAPPED_PORT"-:"$HOST_MAPPED_PORT",hostfwd=tcp::8000-:8000 # export QEMU_OPTS="-nographic" - export QEMU_OPTS="-daemonize -display none -monitor none" + # export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock From 74a1414c5b1f7e4059b1abbcda064aa091641091 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:00:50 -0300 Subject: [PATCH 123/191] Testa qemu.options = [ "-serial mon:stdio -display none -monitor none" ]; --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 15b1b76..f16b977 100644 --- a/flake.nix +++ b/flake.nix @@ -152,7 +152,7 @@ # https://github.com/nix-community/nixos-generators/blob/10079333313ff62446e6f2b0e7c5231c7431d269/formats/vm-nogui.nix#L17C1-L18 graphics = false; - qemu.options = [ "-serial mon:stdio" ]; + qemu.options = [ "-serial mon:stdio -display none -monitor none" ]; }; security.polkit.enable = true; @@ -632,6 +632,7 @@ while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done + exec $SHELL ''; }; }); From 5e3bc38efce54afbc7a856bcd4e4c8b0658c1ca1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:03:29 -0300 Subject: [PATCH 124/191] Testa qemu.options = [ "-serial mon:stdio -display none -monitor none" ]; --- flake.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/flake.nix b/flake.nix index f16b977..39b3698 100644 --- a/flake.nix +++ b/flake.nix @@ -632,7 +632,6 @@ while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done - exec $SHELL ''; }; }); From ca9aaf09ae178f60dd5cb41e4da21bbfdc23eb90 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:04:44 -0300 Subject: [PATCH 125/191] Testa $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 39b3698..d8d7590 100644 --- a/flake.nix +++ b/flake.nix @@ -625,7 +625,7 @@ # ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) - "$RUN_BUID_VM_SCRIPT_PATH" < /dev/null & + $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) # "$RUN_BUID_VM_SCRIPT_PATH" & # TODO: pq o podman.service não está ativo? From 7aa399318228f3ed97838bcfad4dad58acdc27a4 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:05:31 -0300 Subject: [PATCH 126/191] Testa $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &)& --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index d8d7590..f742496 100644 --- a/flake.nix +++ b/flake.nix @@ -625,7 +625,7 @@ # ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) - $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &) + $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &)& # "$RUN_BUID_VM_SCRIPT_PATH" & # TODO: pq o podman.service não está ativo? From 5c7ab796946a44843fd6e1a6026e1de06b844721 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:18:15 -0300 Subject: [PATCH 127/191] Simplica, executa comando diretamente --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index f742496..aa4addb 100644 --- a/flake.nix +++ b/flake.nix @@ -152,7 +152,7 @@ # https://github.com/nix-community/nixos-generators/blob/10079333313ff62446e6f2b0e7c5231c7431d269/formats/vm-nogui.nix#L17C1-L18 graphics = false; - qemu.options = [ "-serial mon:stdio -display none -monitor none" ]; + qemu.options = [ "-serial mon:stdio -display none -monitor none -daemonize" ]; }; security.polkit.enable = true; @@ -625,8 +625,8 @@ # ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket' \ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) - $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &)& - # "$RUN_BUID_VM_SCRIPT_PATH" & + # $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &)& + $RUN_BUID_VM_SCRIPT_PATH" # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From bf9dd59e660e217ee6255dff86146c4015a247af Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:18:59 -0300 Subject: [PATCH 128/191] Fix: quote --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index aa4addb..3ce7352 100644 --- a/flake.nix +++ b/flake.nix @@ -626,7 +626,7 @@ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) # $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &)& - $RUN_BUID_VM_SCRIPT_PATH" + "$RUN_BUID_VM_SCRIPT_PATH" # TODO: pq o podman.service não está ativo? while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ From 23f8d497f58f69854a7718ab89405c5062c2960d Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:20:14 -0300 Subject: [PATCH 129/191] Remove graphics = false; --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 3ce7352..1a80128 100644 --- a/flake.nix +++ b/flake.nix @@ -151,7 +151,7 @@ writableStore = true; # TODO # https://github.com/nix-community/nixos-generators/blob/10079333313ff62446e6f2b0e7c5231c7431d269/formats/vm-nogui.nix#L17C1-L18 - graphics = false; + # graphics = false; qemu.options = [ "-serial mon:stdio -display none -monitor none -daemonize" ]; }; security.polkit.enable = true; From 8e033c26c99934318102902ea7faba06e2717e21 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:21:12 -0300 Subject: [PATCH 130/191] Remove -serial mon:stdio --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 1a80128..d1df142 100644 --- a/flake.nix +++ b/flake.nix @@ -152,7 +152,8 @@ # https://github.com/nix-community/nixos-generators/blob/10079333313ff62446e6f2b0e7c5231c7431d269/formats/vm-nogui.nix#L17C1-L18 # graphics = false; - qemu.options = [ "-serial mon:stdio -display none -monitor none -daemonize" ]; + # qemu.options = [ "-serial mon:stdio -display none -monitor none" ]; + qemu.options = [ "-display none -monitor none -daemonize" ]; }; security.polkit.enable = true; From 987db9a0aee4728509ad6fb4d175b0350511900c Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 9 May 2023 22:28:05 -0300 Subject: [PATCH 131/191] Comenta comando em shellHook --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index d1df142..604a1ef 100644 --- a/flake.nix +++ b/flake.nix @@ -627,11 +627,11 @@ # || ( "$RUN_BUID_VM_SCRIPT_PATH" & ) # $("$RUN_BUID_VM_SCRIPT_PATH" < /dev/null &)& - "$RUN_BUID_VM_SCRIPT_PATH" + # "$RUN_BUID_VM_SCRIPT_PATH" # TODO: pq o podman.service não está ativo? - while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ - echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done + # while ! ssh -T -i "$IDENTITY_FULL_PATH" -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ + # echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done ''; }; From 1a7486bfba0fee735e63234e69cf4c5f58d93ffb Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 10 May 2023 20:08:17 -0300 Subject: [PATCH 132/191] =?UTF-8?q?V=C3=A1rias=20melhorias,=20podman=20fun?= =?UTF-8?q?ciona=20na=20VM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index d7614f0..0ea434c 100644 --- a/profile/README.md +++ b/profile/README.md @@ -738,14 +738,75 @@ build \ .#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm ``` + +```bash +nix \ +develop \ +.# \ +-c \ +"$SHELL" \ +-c \ +'"$RUN_BUID_VM_SCRIPT_PATH"' + +nix \ +develop \ +.# \ +-c \ +"$SHELL" \ +<<'COMMANDS' +while ! ssh -T -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ + echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done +COMMANDS + +nix \ +develop \ +.# \ +-c \ +"$SHELL" \ +-c \ +'podman run -it --rm docker.io/library/alpine sh -c "cat /etc/os-*release"' +``` + +```bash +# TODO: the nix static +# ls -al "$HOME"/.local/share/nix/root/$(nix eval --raw github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm) + +nix \ +develop \ +github:PedroRegisPOAR/.github/987db9a0aee4728509ad6fb4d175b0350511900c \ +-c \ +"$SHELL" \ +-c \ +'"$RUN_BUID_VM_SCRIPT_PATH"' + +nix \ +develop \ +github:PedroRegisPOAR/.github/987db9a0aee4728509ad6fb4d175b0350511900c \ +-c \ +"$SHELL" \ +<<'COMMANDS' +while ! ssh -T -i id_ed25519 -o ConnectTimeout=1 -o StrictHostKeyChecking=no nixuser@localhost -p "$HOST_MAPPED_PORT" <<<'systemctl is-active podman.socket'; do \ + echo $(date +'%d/%m/%Y %H:%M:%S:%3N'); sleep 0.5; done +COMMANDS + +nix \ +develop \ +github:PedroRegisPOAR/.github/987db9a0aee4728509ad6fb4d175b0350511900c \ +-c \ +"$SHELL" \ +-c \ +'podman run -it --rm docker.io/library/alpine sh -c "cat /etc/os-*release"' +``` + ```bash +time \ nix \ build \ --max-jobs auto \ --no-link \ --no-show-trace \ --print-build-logs \ -github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/987db9a0aee4728509ad6fb4d175b0350511900c#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm From 1c8c36a2c81a14445f3f16c61014f397315f5cef Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 10 May 2023 20:41:27 -0300 Subject: [PATCH 133/191] Cria VM nixosBuildVMAarch64LinuxPodman --- flake.nix | 211 +++++++++++++++++++++++++++++++++++++++++++++- profile/README.md | 1 + 2 files changed, 211 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 604a1ef..b9fa36f 100644 --- a/flake.nix +++ b/flake.nix @@ -97,8 +97,217 @@ gitFull xorg.xclock file + btop # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello + + # firefox + # vscode + # (python3.buildEnv.override + # { + # extraLibs = with python3Packages; [ scikitimage opencv2 numpy ]; + # } + # ) + ]; + shell = pkgs.bashInteractive; + uid = 1234; + autoSubUidGidRange = true; + + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly" + ]; + }; + + systemd.services.adds-change-workdir = { + script = "echo cd /tmp/shared >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.services.creates-if-not-exist = { + script = "echo touch /home/nixuser/.Xauthority >> /home/nixuser/.profile"; + wantedBy = [ "multi-user.target" ]; + }; + + # https://unix.stackexchange.com/questions/619671/declaring-a-sym-link-in-a-users-home-directory#comment1159159_619703 + systemd.services.populate-history = { + script = "echo \"ls -al /nix/store\" >> /home/nixuser/.bash_history"; + wantedBy = [ "multi-user.target" ]; + }; + + virtualisation = { + # following configuration is added only when building VM with build-vm + memorySize = 3072; # Use MiB memory. + + # nixos-disk-image> ERROR: cptofs failed. diskSize might be too small for closure. + diskSize = 15*1024; # Use MiB memory. + cores = 7; # Simulate 3 cores. + # + podman.enable = true; + + # + useNixStoreImage = true; + writableStore = true; # TODO + + # https://github.com/nix-community/nixos-generators/blob/10079333313ff62446e6f2b0e7c5231c7431d269/formats/vm-nogui.nix#L17C1-L18 + # graphics = false; + # qemu.options = [ "-serial mon:stdio -display none -monitor none" ]; + qemu.options = [ "-display none -monitor none -daemonize" ]; + }; + security.polkit.enable = true; + + # https://nixos.wiki/wiki/Libvirt + boot.extraModprobeConfig = "options kvm_intel nested=1"; + boot.kernelModules = [ + "kvm-intel" + "vfio-pci" + ]; + + # hardware.opengl.enable = true; + # hardware.opengl.driSupport = true; + + nixpkgs.config.allowUnfree = true; + nix = { + package = pkgs.nix; + # package = pkgsCross.aarch64-multiplatform-musl.pkgsStatic.nix; + extraOptions = "experimental-features = nix-command flakes"; + readOnlyStore = true; + }; + + boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + + # Enable the X11 windowing system. + services.xserver = { + enable = true; + displayManager.gdm.enable = true; + displayManager.startx.enable = true; + logFile = "/var/log/X.0.log"; + desktopManager.xterm.enable = true; + # displayManager.gdm.autoLogin.enable = true; + # displayManager.gdm.autoLogin.user = "nixuser"; + }; + services.spice-vdagentd.enable = true; + + # https://github.com/NixOS/nixpkgs/issues/21332#issuecomment-268730694 + services.openssh = { + allowSFTP = true; + kbdInteractiveAuthentication = false; + enable = true; + forwardX11 = true; + passwordAuthentication = false; + permitRootLogin = "yes"; + ports = [ 10022 ]; + authorizedKeysFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + + # https://stackoverflow.com/a/71247061 + # https://nixos.wiki/wiki/Firewall + networking.firewall = { + enable = true; + allowedTCPPorts = [ 22 80 443 10022 8000 ]; + }; + + programs.ssh.forwardX11 = true; + services.qemuGuest.enable = true; + + services.sshd.enable = true; + + programs.dconf.enable = true; + + time.timeZone = "America/Recife"; + system.stateVersion = "22.11"; + + users.users.root = { + password = "root"; + initialPassword = "root"; + openssh.authorizedKeys.keyFiles = [ + "${ ./nixuser-keys.pub }" + ]; + }; + }) + ]; + }; + + + nixosConfigurations.nixosBuildVMAarch64LinuxPodman = + let + pkgs = import nixpkgs { + system = "aarch64-linux"; + config = { allowUnfree = true; }; + }; + in + nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + # system = "aarch64-linux"; + modules = + let + nixuserKeys = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKyhLx5HU63zJJ5Lx4j+NTC/OQZ7Weloc8y+On467kly"; + in + [ + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/build-vm.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-vm.nix" + # "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/virtualisation/qemu-guest.nix" + "${toString (builtins.getFlake "github:NixOS/nixpkgs/a8f8b7db23ec6450e384da183d270b18c58493d4")}/nixos/modules/installer/cd-dvd/channel.nix" + + ({ + # https://gist.github.com/andir/88458b13c26a04752854608aacb15c8f#file-configuration-nix-L11-L12 + boot.loader.grub.extraConfig = "serial --unit=0 --speed=115200 \n terminal_output serial console; terminal_input serial console"; + boot.kernelParams = [ + "console=tty0" + "console=ttyS0,115200n8" + # Set sensible kernel parameters + # https://nixos.wiki/wiki/Bootloader + # https://git.redbrick.dcu.ie/m1cr0man/nix-configs-rb/commit/ddb4d96dacc52357e5eaec5870d9733a1ea63a5a?lang=pt-PT + "boot.shell_on_fail" + "panic=30" + "boot.panic_on_fail" # reboot the machine upon fatal boot issues + # TODO: test it + "intel_iommu=on" + "iommu=pt" + + # https://discuss.linuxcontainers.org/t/podman-wont-run-containers-in-lxd-cgroup-controller-pids-unavailable/13049/2 + # https://github.com/NixOS/nixpkgs/issues/73800#issuecomment-729206223 + # https://github.com/canonical/microk8s/issues/1691#issuecomment-977543458 + # https://github.com/grahamc/nixos-config/blob/35388280d3b06ada5882d37c5b4f6d3baa43da69/devices/petunia/configuration.nix#L36 + # cgroup_no_v1=all + "swapaccount=0" + "systemd.unified_cgroup_hierarchy=0" + "group_enable=memory" + ]; + + boot.tmpOnTmpfs = false; + # https://github.com/AtilaSaraiva/nix-dotfiles/blob/main/lib/modules/configHost/default.nix#L271-L273 + boot.tmpOnTmpfsSize = "100%"; + + # https://nixos.wiki/wiki/NixOS:nixos-rebuild_build-vm + users.extraGroups.nixgroup.gid = 999; + + users.users.nixuser = { + isSystemUser = true; + password = "1"; + createHome = true; + home = "/home/nixuser"; + homeMode = "0700"; + description = "The VM tester user"; + group = "nixgroup"; + extraGroups = [ + "podman" + "kvm" + "libvirtd" + "wheel" + ]; + packages = with pkgs; [ + direnv + gitFull + xorg.xclock + file btop + # pkgsCross.aarch64-multiplatform-musl.pkgsStatic.hello + # firefox # vscode # (python3.buildEnv.override @@ -610,7 +819,7 @@ # export QEMU_OPTS="-nographic" # export QEMU_OPTS="-daemonize -display none -monitor none" export SHARED_DIR="$(pwd)" - export RUN_BUID_VM_SCRIPT_PATH="${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm + export RUN_BUID_VM_SCRIPT_PATH="''${self.nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm}"/bin/run-nixos-vm export CONTAINER_HOST=ssh://"$NIXOS_VM_USER"@localhost:"$HOST_MAPPED_PORT"/run/user/1234/podman/podman.sock "$REMOVE_DISK" && rm -fv nixos.qcow2 diff --git a/profile/README.md b/profile/README.md index 0ea434c..78b3483 100644 --- a/profile/README.md +++ b/profile/README.md @@ -3,6 +3,7 @@ ```bash git clone git@github.com:PedroRegisPOAR/.github.git \ && cd .github \ +&& git checkout feature/dx-with-nix-and-home-manager \ && ((direnv 1>/dev/null 2>/dev/null && direnv allow) || nix develop .#) ``` From 0e2eea32d0f790719309a9f6de072823107107cc Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 11 May 2023 11:21:06 -0300 Subject: [PATCH 134/191] =?UTF-8?q?Varias=20corre=C3=A7=C3=B5es=20lauchctl?= =?UTF-8?q?=20->=20launchctl,=20e=20testes=20aarch64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 115 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 13 deletions(-) diff --git a/profile/README.md b/profile/README.md index 78b3483..82a93a4 100644 --- a/profile/README.md +++ b/profile/README.md @@ -14,7 +14,7 @@ git clone git@github.com:PedroRegisPOAR/.github.git \ Versão curta: ```bash -wget -qO- http://ix.io/4vmd | sh \ +wget -qO- http://ix.io/4vCI | sh \ && . "$HOME"/."$(basename $SHELL)"rc \ && nix flake --version ``` @@ -27,8 +27,8 @@ wget -qO- http://ix.io/4vmd | sh \ command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) command -v curl || (command -v apk && sudo apk add --no-cache curl) -# DAEMON_OR_NO_DAEMON='--'"$((lauchctl --version 1>/dev/null 2>/dev/null || systemctl --version 1>/dev/null 2>/dev/null) && echo daemon || echo no-daemon)" -DAEMON_OR_NO_DAEMON='--'"$($(lauchctl --version 1>/dev/null 2>/dev/null) && echo daemon || echo no-daemon)" +# DAEMON_OR_NO_DAEMON='--'"$((launchctl version 1>/dev/null 2>/dev/null || systemctl --version 1>/dev/null 2>/dev/null) && echo daemon || echo no-daemon)" +DAEMON_OR_NO_DAEMON='--'"$($(launchctl version 1>/dev/null 2>/dev/null) && echo daemon || echo no-daemon)" NIX_RELEASE_VERSION=2.10.2 \ @@ -55,7 +55,7 @@ Para criar a versão curta, crie um arquivo e copie e cole o bloco de código ac nano arquivo.txt ``` -Após salvar: +Após salvar e fechar o arquivo: ```bash cat arquivo.txt | curl -F 'f:1=<-' ix.io ``` @@ -71,6 +71,16 @@ programas com interface gráfica. 1.1) Apenas programas CLI: + +Versão curta: +```bash +wget -qO- http://ix.io/4udG | sh +``` + + +
+ Versão longa (click para expandir): + ```bash # Precisa das variáveis de ambiente USER e HOME @@ -81,9 +91,26 @@ DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs export DUMMY_USER="$USER" # export DUMMY_USER="$(id -un)" -# TODO: Mac -# export DUMMY_HOME="$HOME" -export DUMMY_HOME=/home/"$USER" +IS_DARWIN=$(nix eval --impure --expr '((builtins.getFlake "github:NixOS/nixpkgs").legacyPackages.${builtins.currentSystem}.stdenv.isDarwin)') +IS_LINUX=$(nix eval --impure --expr '((builtins.getFlake "github:NixOS/nixpkgs").legacyPackages.${builtins.currentSystem}.stdenv.isLinux)') + + +FLAKE_ARCHITECTURE=$(nix eval --impure --raw --expr 'builtins.currentSystem'). + +if [ "$IS_DARWIN" = "true" ]; then + echo 'The system archtecture was detected as: '"$FLAKE_ARCHITECTURE" + DUMMY_HOME_PREFIX='/Users' +fi + +if [ "$IS_LINUX" = "true" ]; then + echo 'The system archtecture was detected as: '"$FLAKE_ARCHITECTURE" + DUMMY_HOME_PREFIX='/home' +fi + + +CONFIG_NIXPKGS=${OVERRIDE_DIRECTORY_CONFIG_NIXPKGS:-.config/nixpkgs} + +export DUMMY_HOME="$DUMMY_HOME_PREFIX"/"$USER" # export DUMMY_HOSTNAME=alpine316.localdomain export DUMMY_HOSTNAME="$(hostname)" @@ -174,12 +201,15 @@ bash <<-EOF EOF ``` +
+ -Versão curta: ```bash -wget -qO- http://ix.io/4uz3 | sh \ -&& . "$HOME"/."$(basename $SHELL)"rc \ -&& nix flake --version +# TODO: se não existir criar? +create-nix-hardcoded-sign-cache-keys + +send-signed-closure-run-time-of-flake-uri-attr-to-bucket \ +"$HOME"/.config/nixpkgs#'homeConfigurations."vagrant-alpine316.localdomain".activationPackage' ``` @@ -187,14 +217,14 @@ wget -qO- http://ix.io/4uz3 | sh \ nix \ --option eval-cache false \ --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ ---option extra-substituters https://playing-bucket-nix-cache-test.s3.amazonaws.com \ +--option extra-substituters "s3://playing-bucket-nix-cache-test" \ build \ --keep-failed \ --max-jobs 0 \ --no-link \ --print-build-logs \ --print-out-paths \ -/nix/store/8c3ssm2avqxyfhcz7jik9s857s3kyz0q-home-manager-generation +/nix/store/a7mqcffbs91k9r3g7qvc7kax2kpabn7m-home-manager-generation ``` ```bash @@ -1199,3 +1229,62 @@ PID=? tr '\0' '\n' < /proc/${PID}/cmdline strace -f -T -y -e trace=file ``` + + +### Caching + + + +```bash +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys 'binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg=' \ +--option extra-trusted-substituters 's3://playing-bucket-nix-cache-test/' \ +build \ +--keep-failed \ +--max-jobs 0 \ +--no-link \ +--print-build-logs \ +--print-out-paths \ +github:PedroRegisPOAR/.github/1c8c36a2c81a14445f3f16c61014f397315f5cef#nixosConfigurations.aarch64-linux.nixosBuildVMAarch64LinuxPodman.config.system.build.vm + + +nix \ +--option eval-cache false \ +--option extra-trusted-public-keys 'binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg=' \ +--option extra-trusted-substituters 's3://playing-bucket-nix-cache-test/' \ +build \ +--keep-failed \ +--max-jobs auto \ +--no-link \ +--print-build-logs \ +--print-out-paths \ +github:PedroRegisPOAR/.github/1c8c36a2c81a14445f3f16c61014f397315f5cef#nixosConfigurations.aarch64-linux.nixosBuildVMAarch64LinuxPodman.config.system.build.vm +``` + + +```bash +trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= +trusted-substituters = s3://playing-bucket-nix-cache-test/ +trusted-users = root alvaro +build-users-group = nixbld +``` + +```bash +sudo rm -frv nixos.qcow2 keys +``` + +```bash +sudo nix --extra-experimental-features 'nix-command flakes' run nixpkgs#darwin.builder +``` + +```bash +qemu-system-aarch64 -accel help +``` + + +```bash +Accelerators supported in QEMU binary: +hvf +tcg +``` From faf606f8a9a4fec840b1fdc4d0893a6dd9bbf88f Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 11 May 2023 13:14:02 -0300 Subject: [PATCH 135/191] WIP no suporte a Mac, ainda em progresso, separou-se os instaladores --- profile/README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/profile/README.md b/profile/README.md index 82a93a4..da07b0e 100644 --- a/profile/README.md +++ b/profile/README.md @@ -12,7 +12,7 @@ git clone git@github.com:PedroRegisPOAR/.github.git \ 1) Instalação do nix single user. -Versão curta: +Versão curta: para linux ```bash wget -qO- http://ix.io/4vCI | sh \ && . "$HOME"/."$(basename $SHELL)"rc \ @@ -60,10 +60,49 @@ Após salvar e fechar o arquivo: cat arquivo.txt | curl -F 'f:1=<-' ix.io ``` -Basta atualizar a versão curta da instalação. +Basta atualizar o hash/id da instalação. + +
+ +### Mac + + +Versão curta: +```bash +curl -L http://ix.io/4vEW | sh +``` + +É obrigatório que o terminal seja fechado. + +Após abrir o terminal: +```bash +nix profile install nixpkgs#{direnv,git,direnv} +``` + +
+ Versão longa Mac (click para expandir): + +```bash +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ +&& echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile +``` + +Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. +```bash +nano arquivo.txt +``` + +Após salvar e fechar o arquivo: +```bash +cat arquivo.txt | curl -F 'f:1=<-' ix.io +``` + +Basta atualizar o hash/id da instalação.
+ ## Parte 2, home-manager + nix Existem 3 tipos de configurações, descritos nas próximas seções: apenas CLI, apenas CLI slim, e com From 62e58729ac291a9afab7077671cdc0a48136a3a9 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 17 May 2023 00:29:16 -0300 Subject: [PATCH 136/191] WIP: nix mult user or daemon --- profile/README.md | 61 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/profile/README.md b/profile/README.md index da07b0e..ffc025d 100644 --- a/profile/README.md +++ b/profile/README.md @@ -7,10 +7,8 @@ git clone git@github.com:PedroRegisPOAR/.github.git \ && ((direnv 1>/dev/null 2>/dev/null && direnv allow) || nix develop .#) ``` -## Template - -1) Instalação do nix single user. +1) Instalação do nix para apenas UM usuário, _single user_, que é equivalente a usar a flag `--no-daemon`. Versão curta: para linux ```bash @@ -64,6 +62,61 @@ Basta atualizar o hash/id da instalação. + + +2) Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador, _multi user_, que é +equivalente a usar a flag `--daemon`. + + +Parte 2.1) +```bash +command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) +command -v curl || (command -v apk && sudo apk add --no-cache curl) + +DAEMON_OR_NO_DAEMON='--daemon' + + +NIX_RELEASE_VERSION=2.10.2 \ +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- "$DAEMON_OR_NO_DAEMON" \ +&& exit 0 +``` + + +Parte 2.2) +```bash +sudo \ +$SHELL \ +<<'COMMANDS' +NAME_SHELL=$(basename $SHELL) \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo '. "$HOME"/.nix-profile/etc/profile.d/nix.sh' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/.profile \ +&& echo '. "$HOME"/.nix-profile/etc/profile.d/nix.sh' >> "$HOME"/.profile \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile \ +&& . "$HOME"/."$NAME_SHELL"rc \ +&& . "$HOME"/.profile \ +&& nix flake --version \ +&& nix --extra-experimental-features 'nix-command flakes' profile install -vvv nixpkgs#direnv nixpkgs#git \ +&& . "$HOME"/."$NAME_SHELL"rc \ +&& . "$HOME"/.profile +COMMANDS + + +NAME_SHELL=$(basename $SHELL) \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/.profile \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile \ +&& . "$HOME"/."$NAME_SHELL"rc \ +&& . "$HOME"/.profile \ +&& nix flake --version \ +&& nix --extra-experimental-features 'nix-command flakes' profile install -vvv nixpkgs#direnv nixpkgs#git \ +&& . "$HOME"/."$NAME_SHELL"rc \ +&& . "$HOME"/.profile +``` + + ### Mac @@ -76,7 +129,7 @@ curl -L http://ix.io/4vEW | sh Após abrir o terminal: ```bash -nix profile install nixpkgs#{direnv,git,direnv} +nix profile install nixpkgs#{direnv,git,direnv,curl,wget} ```
From 9a37aa64dde0aedcb7da3c3d588455510ca00acb Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 18 May 2023 14:07:15 -0300 Subject: [PATCH 137/191] WIP --- profile/README.md | 68 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/profile/README.md b/profile/README.md index ffc025d..2ebde1c 100644 --- a/profile/README.md +++ b/profile/README.md @@ -77,13 +77,8 @@ DAEMON_OR_NO_DAEMON='--daemon' NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- "$DAEMON_OR_NO_DAEMON" \ -&& exit 0 -``` - +&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- "$DAEMON_OR_NO_DAEMON" -Parte 2.2) -```bash sudo \ $SHELL \ <<'COMMANDS' @@ -103,6 +98,55 @@ NAME_SHELL=$(basename $SHELL) \ COMMANDS +sudo ln -sfv "$HOME"/.nix-profile /nix/var/nix/profiles/default/ \ +&& sudo "$SHELL" -lc 'nix profile install -vvv nixpkgs#direnv nixpkgs#git --profile '"$HOME"'/.nix-profile' \ +&& NAME_SHELL=$(basename $SHELL) \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/.profile \ +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile +``` + +```bash +echo 'Start group stuff...' \ +&& SUDO_ADMIN_GROUP_NAME='sudo' \ +&& getent group "$SUDO_ADMIN_GROUP_NAME" || sudo groupadd "$SUDO_ADMIN_GROUP_NAME" \ +&& sudo usermod --append --groups "$SUDO_ADMIN_GROUP_NAME" "$USER" \ +&& echo 'End group stuff!' +``` + +```bash +sudo chown $(id -u):$(id -g) /nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/new{u,g}idmap +``` + + +```bash +$(test $(stat -c %u:%g /nix/store) = $(id -u):$(id -g)) \ +|| sudo chown $(id -u):$(id -g) /nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/new{u,g}idmap +``` + +```bash +test $(stat -c %u:%g /nix) = 0:0 +``` + + +podman --version + +```bash +podman info 1> /dev/null 2> /dev/null \ +|| sudo chown $(id -u):$(id -g) /nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/new{u,g}idmap +``` + +Feche o terminal. + +Parte 2.2) + +Abra o terminal novamente e cole o código abaixo: +```bash +sudo \ +su \ +"$USER" \ +<<'COMMANDS' NAME_SHELL=$(basename $SHELL) \ && echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ && echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ @@ -114,9 +158,21 @@ NAME_SHELL=$(basename $SHELL) \ && nix --extra-experimental-features 'nix-command flakes' profile install -vvv nixpkgs#direnv nixpkgs#git \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile +COMMANDS ``` +nix run nixpkgs#nix-info -- -m + + - system: `"x86_64-linux"` + - host os: `Linux 5.15.0-58-generic, Ubuntu, 22.04.1 LTS (Jammy Jellyfish), nobuild` + - multi-user?: `yes` + - sandbox: `yes` + - version: `nix-env (Nix) 2.10.2` + - channels(root): `"nixpkgs"` + - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs + + ### Mac From 7a8f1ee99f001c63da5cf8db123744544316cb70 Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 19 May 2023 09:27:12 -0300 Subject: [PATCH 138/191] WIP --- profile/README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/profile/README.md b/profile/README.md index 2ebde1c..cc5c449 100644 --- a/profile/README.md +++ b/profile/README.md @@ -68,6 +68,13 @@ Basta atualizar o hash/id da instalação. equivalente a usar a flag `--daemon`. +Versão curta: para linux +```bash +wget -qO- http://ix.io/4w9r | sh \ +&& . "$HOME"/."$(basename $SHELL)"rc \ +&& nix flake --version +``` + Parte 2.1) ```bash command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) @@ -129,16 +136,26 @@ $(test $(stat -c %u:%g /nix/store) = $(id -u):$(id -g)) \ test $(stat -c %u:%g /nix) = 0:0 ``` +```bash +NOME_DO_SEU_USER=testuser + +sudo useradd -m -s "$SHELL" "$NOME_DO_SEU_USER" +sudo usermod --append --groups sudo "$NOME_DO_SEU_USER" +sudo passwd "$NOME_DO_SEU_USER" +``` -podman --version ```bash podman info 1> /dev/null 2> /dev/null \ -|| sudo chown $(id -u):$(id -g) /nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/new{u,g}idmap +|| sudo chown -v $(id -u):sudo /nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/new{u,g}idmap ``` Feche o terminal. +Notas: +- [Allow gc-ing with a rootless daemon](https://github.com/NixOS/nix/pull/5380) +- [Extra-secure store objects that Nix cannot modify](https://github.com/NixOS/nix/issues/7471) + Parte 2.2) Abra o terminal novamente e cole o código abaixo: From f0f20604a633ddb5237d9da98ba4ff7b2e0c351b Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Fri, 19 May 2023 15:47:54 -0300 Subject: [PATCH 139/191] =?UTF-8?q?Melhora=20c=C3=B3digos,=20reorganiza=20?= =?UTF-8?q?e=20documenta,=20relacionado=20=C3=A0=20newuidmap/newgidmap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/profile/README.md b/profile/README.md index cc5c449..aac1a4b 100644 --- a/profile/README.md +++ b/profile/README.md @@ -114,6 +114,40 @@ sudo ln -sfv "$HOME"/.nix-profile /nix/var/nix/profiles/default/ \ && echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile ``` + +Cria um usuário com: +- `$HOME`; +- participante do grupo `sudo`, ou seja, equivalente a permissão `root`; +- configura uma senha para esse user. + +```bash +NOME_DO_SEU_USER=testuser + +sudo useradd -m -s "$SHELL" "$NOME_DO_SEU_USER" +sudo usermod --append --groups sudo "$NOME_DO_SEU_USER" +sudo passwd "$NOME_DO_SEU_USER" + +# TODO: talvez o snipet abaixo possa ser mergido com esse aproveitando que se sabe o "home do user" pois se tem o nome do user +``` + + +Para cada usuário criado é necessário adicionar esse "hack" para poder utilizar o `podman`: +```bash +NAME_SHELL=$(basename $SHELL) + +tee -a "$HOME"/."$NAME_SHELL"rc <<'EOF' +FULL_PATH_TO_UIDMAP='/nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/newuidmap' +FULL_PATH_TO_GIDMAP='/nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/newgidmap' + +$(test $(stat -c %u:%g "$FULL_PATH_TO_UIDMAP") = $(id -u):$(id -g)) || sudo chown -v $(id -u):$(id -g) "$FULL_PATH_TO_UIDMAP" +$(test $(stat -c %u:%g "$FULL_PATH_TO_GIDMAP") = $(id -u):$(id -g)) || sudo chown -v $(id -u):$(id -g) "$FULL_PATH_TO_GIDMAP" + +unset FULL_PATH_TO_UIDMAP +unset FULL_PATH_TO_GIDMAP +EOF +``` + + ```bash echo 'Start group stuff...' \ && SUDO_ADMIN_GROUP_NAME='sudo' \ @@ -136,13 +170,7 @@ $(test $(stat -c %u:%g /nix/store) = $(id -u):$(id -g)) \ test $(stat -c %u:%g /nix) = 0:0 ``` -```bash -NOME_DO_SEU_USER=testuser -sudo useradd -m -s "$SHELL" "$NOME_DO_SEU_USER" -sudo usermod --append --groups sudo "$NOME_DO_SEU_USER" -sudo passwd "$NOME_DO_SEU_USER" -``` ```bash From a1277708b664dd9176a167876d6486a1f8f6cbfb Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Fri, 19 May 2023 16:08:06 -0300 Subject: [PATCH 140/191] Testa colapsar bloco do nix mult user --- profile/README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/profile/README.md b/profile/README.md index aac1a4b..a86f241 100644 --- a/profile/README.md +++ b/profile/README.md @@ -70,12 +70,12 @@ equivalente a usar a flag `--daemon`. Versão curta: para linux ```bash -wget -qO- http://ix.io/4w9r | sh \ -&& . "$HOME"/."$(basename $SHELL)"rc \ -&& nix flake --version +wget -qO- http://ix.io/4w9r | sh ``` -Parte 2.1) +
+ Versão longa (click para expandir): + ```bash command -v curl || (command -v apt && sudo apt-get update && sudo apt-get install -y curl) command -v curl || (command -v apk && sudo apk add --no-cache curl) @@ -114,6 +114,20 @@ sudo ln -sfv "$HOME"/.nix-profile /nix/var/nix/profiles/default/ \ && echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile ``` +Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. +```bash +nano arquivo.txt +``` + +Após salvar e fechar o arquivo: +```bash +cat arquivo.txt | curl -F 'f:1=<-' ix.io +``` + +Basta atualizar o hash/id da instalação. + +
+ Cria um usuário com: - `$HOME`; @@ -184,7 +198,7 @@ Notas: - [Allow gc-ing with a rootless daemon](https://github.com/NixOS/nix/pull/5380) - [Extra-secure store objects that Nix cannot modify](https://github.com/NixOS/nix/issues/7471) -Parte 2.2) +Parte old) Abra o terminal novamente e cole o código abaixo: ```bash From 0e8fafc372833c266e9d3a91d4e015fa5c1b6c55 Mon Sep 17 00:00:00 2001 From: PedroRegisPOAR Date: Fri, 19 May 2023 16:09:51 -0300 Subject: [PATCH 141/191] Adiciona quebras de linha --- profile/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/profile/README.md b/profile/README.md index a86f241..e92aef6 100644 --- a/profile/README.md +++ b/profile/README.md @@ -150,6 +150,7 @@ Para cada usuário criado é necessário adicionar esse "hack" para poder utiliz NAME_SHELL=$(basename $SHELL) tee -a "$HOME"/."$NAME_SHELL"rc <<'EOF' + FULL_PATH_TO_UIDMAP='/nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/newuidmap' FULL_PATH_TO_GIDMAP='/nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/newgidmap' @@ -158,6 +159,7 @@ $(test $(stat -c %u:%g "$FULL_PATH_TO_GIDMAP") = $(id -u):$(id -g)) || sudo chow unset FULL_PATH_TO_UIDMAP unset FULL_PATH_TO_GIDMAP + EOF ``` From ee28f528812fc3bc0ea2c84908157e5abf79611a Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 21 Jun 2023 20:43:44 -0300 Subject: [PATCH 142/191] Usa hash nos inputs --- profile/README.md | 3 ++- templates/start-slim-config/flake.nix | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index e92aef6..7dc46b3 100644 --- a/profile/README.md +++ b/profile/README.md @@ -43,7 +43,8 @@ NAME_SHELL=$(basename $SHELL) \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile \ && nix flake --version \ -&& nix --extra-experimental-features 'nix-command flakes' profile install -vvv nixpkgs#direnv nixpkgs#git \ +&& nix --extra-experimental-features 'nix-command flakes' -vv registry pin nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ +&& nix --extra-experimental-features 'nix-command flakes' -vv profile install nixpkgs#direnv nixpkgs#git \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile ``` diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 96c7238..8ce6236 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -3,8 +3,11 @@ inputs = { # Specify the source of Home Manager and Nixpkgs - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + # nix flake metadata github:nix-community/home-manager/release-22.11 + home-manager.url = "github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc"; + + # nix flake metadata github:nixos/nixpkgs/release-22.11 + nixpkgs.url = "github:nixos/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; From 41b26fab6d0afdf350b2db6733c99a8a41cd337c Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 21 Jun 2023 20:47:05 -0300 Subject: [PATCH 143/191] Sincroniza nixpkgs, talvez evite um download --- flake.lock | 32 +++++++++++++++++++++++++------- flake.nix | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/flake.lock b/flake.lock index aecaf9d..6d901c2 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1687171271, + "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", "type": "github" }, "original": { @@ -17,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1678298120, - "narHash": "sha256-iaV5xqgn29xy765Js3EoZePQyZIlLZA3pTYtTnKkejg=", - "owner": "NixOS", + "lastModified": 1671313200, + "narHash": "sha256-itZTrtHeDJjV696+ur0/TzkTqb5y3Eb57WRLRPK3rwA=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "1e383aada51b416c6c27d4884d2e258df201bc11", + "rev": "0938d73bb143f4ae037143572f11f4338c7b2d1c", "type": "github" }, "original": { @@ -34,6 +37,21 @@ "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index b9fa36f..b0f2218 100644 --- a/flake.nix +++ b/flake.nix @@ -804,7 +804,7 @@ curl gnumake patchelf - poetry + # poetry python3Full tmate ]; From 6fa7a5d2f8d7de37a3fcc88986a97d063ab68d86 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 22 Jun 2023 19:41:08 -0300 Subject: [PATCH 144/191] Refactor: pina nixpkgs --- profile/README.md | 22 ++++++++++++---------- templates/start-slim-config/flake.nix | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/profile/README.md b/profile/README.md index 7dc46b3..27d4270 100644 --- a/profile/README.md +++ b/profile/README.md @@ -301,8 +301,9 @@ DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs export DUMMY_USER="$USER" # export DUMMY_USER="$(id -un)" -IS_DARWIN=$(nix eval --impure --expr '((builtins.getFlake "github:NixOS/nixpkgs").legacyPackages.${builtins.currentSystem}.stdenv.isDarwin)') -IS_LINUX=$(nix eval --impure --expr '((builtins.getFlake "github:NixOS/nixpkgs").legacyPackages.${builtins.currentSystem}.stdenv.isLinux)') +IS_DARWIN=$(nix eval nixpkgs#stdenv.isDarwin) +IS_LINUX=$(nix eval nixpkgs#stdenv.isLinux) + FLAKE_ARCHITECTURE=$(nix eval --impure --raw --expr 'builtins.currentSystem'). @@ -331,12 +332,12 @@ FLAKE_ATTR="$DIRECTORY_TO_CLONE""#homeConfigurations."'\"'"$HM_ATTR_FULL_NAME"'\ BASE_FLAKE_URI='github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#' +# --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +# --option extra-substituters "s3://playing-bucket-nix-cache-test" \ time \ nix \ --extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ ---option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ ---option extra-substituters "s3://playing-bucket-nix-cache-test" \ shell \ "$BASE_FLAKE_URI"git \ "$BASE_FLAKE_URI"bashInteractive \ @@ -367,20 +368,21 @@ bash <<-EOF && git init \ && git status \ && git add . \ - && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb \ + && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ && git status \ && git add . - + echo "$FLAKE_ATTR" - # TODO: --max-jobs 0 \ + # TODO: + # --max-jobs 0 \ + # --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ + # --option extra-substituters "s3://playing-bucket-nix-cache-test" \ + nix \ --extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ - --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ - --option extra-substituters "s3://playing-bucket-nix-cache-test" \ build \ --keep-failed \ - --max-jobs 0 \ --no-link \ --print-build-logs \ --print-out-paths \ diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 8ce6236..3e92edb 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -24,6 +24,8 @@ pkgs = nixpkgs.legacyPackages.${system}; modules = [ + # https://discourse.nixos.org/t/flakes-error-error-attribute-outpath-missing/18044/2 + ({...}: { nix.registry.nixpkgs.flake = nixpkgs; }) { home = { inherit username; From f5a993237d0be630da41d1628325736c8e54da14 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 22 Jun 2023 20:24:47 -0300 Subject: [PATCH 145/191] Refactor: pina nixpkgs --- profile/README.md | 23 +++++++---------------- templates/start-slim-config/home.nix | 2 +- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/profile/README.md b/profile/README.md index 27d4270..4b43c5d 100644 --- a/profile/README.md +++ b/profile/README.md @@ -293,19 +293,15 @@ wget -qO- http://ix.io/4udG | sh ```bash # Precisa das variáveis de ambiente USER e HOME +test $USER || echo The USER variable is not set && exit 1 +test $HOME || echo The HOME variable is not set && exit 1 -DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs - - -# export DUMMY_USER=alpine -export DUMMY_USER="$USER" # export DUMMY_USER="$(id -un)" +export DUMMY_USER="$USER" +DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs IS_DARWIN=$(nix eval nixpkgs#stdenv.isDarwin) IS_LINUX=$(nix eval nixpkgs#stdenv.isLinux) - - - FLAKE_ARCHITECTURE=$(nix eval --impure --raw --expr 'builtins.currentSystem'). if [ "$IS_DARWIN" = "true" ]; then @@ -318,19 +314,16 @@ if [ "$IS_LINUX" = "true" ]; then DUMMY_HOME_PREFIX='/home' fi - +# Útil para testar usando um diretório diferente: CONFIG_NIXPKGS=${OVERRIDE_DIRECTORY_CONFIG_NIXPKGS:-.config/nixpkgs} export DUMMY_HOME="$DUMMY_HOME_PREFIX"/"$USER" - -# export DUMMY_HOSTNAME=alpine316.localdomain export DUMMY_HOSTNAME="$(hostname)" HM_ATTR_FULL_NAME='"'"$DUMMY_USER"-"$DUMMY_HOSTNAME"'"' FLAKE_ATTR="$DIRECTORY_TO_CLONE""#homeConfigurations."'\"'"$HM_ATTR_FULL_NAME"'\"'".activationPackage" - -BASE_FLAKE_URI='github:NixOS/nixpkgs/f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb#' +BASE_FLAKE_URI='github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c#' # --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ # --option extra-substituters "s3://playing-bucket-nix-cache-test" \ @@ -353,7 +346,6 @@ bash <<-EOF cd $DIRECTORY_TO_CLONE export NIX_CONFIG='extra-experimental-features = nix-command flakes' - echo $NIX_CONFIG nix \ @@ -377,7 +369,6 @@ bash <<-EOF # --max-jobs 0 \ # --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ # --option extra-substituters "s3://playing-bucket-nix-cache-test" \ - nix \ --extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ @@ -391,7 +382,7 @@ bash <<-EOF nix --extra-experimental-features 'nix-command flakes' -vvv profile remove '.*' export NIXPKGS_ALLOW_UNFREE=1 \ - && home-manager switch -b backuphm --impure --flake \ + && home-manager switch --backup backuphm --impure --flake \ "$DIRECTORY_TO_CLONE"#"$HM_ATTR_FULL_NAME" \ && home-manager generations diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 759c42b..f8967b8 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -488,7 +488,7 @@ settings = { # use-sandbox = true; - show-trace = true; + show-trace = false; # system-features = [ "big-parallel" "kvm" "recursive-nix" "nixos-test" ]; keep-outputs = true; keep-derivations = true; From f5077791898b8ff3efa169ac7bc5eba1ed9ce67a Mon Sep 17 00:00:00 2001 From: Pedro Date: Fri, 23 Jun 2023 09:00:46 -0300 Subject: [PATCH 146/191] Nova URL, debug --- profile/README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/profile/README.md b/profile/README.md index 4b43c5d..7219324 100644 --- a/profile/README.md +++ b/profile/README.md @@ -293,9 +293,6 @@ wget -qO- http://ix.io/4udG | sh ```bash # Precisa das variáveis de ambiente USER e HOME -test $USER || echo The USER variable is not set && exit 1 -test $HOME || echo The HOME variable is not set && exit 1 - # export DUMMY_USER="$(id -un)" export DUMMY_USER="$USER" DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs @@ -382,7 +379,7 @@ bash <<-EOF nix --extra-experimental-features 'nix-command flakes' -vvv profile remove '.*' export NIXPKGS_ALLOW_UNFREE=1 \ - && home-manager switch --backup backuphm --impure --flake \ + && home-manager switch -b backuphm --impure --flake \ "$DIRECTORY_TO_CLONE"#"$HM_ATTR_FULL_NAME" \ && home-manager generations From b8a7a18cb2c035fd2d6d6aa086faf7b1c62c14d2 Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 23 Jun 2023 11:27:14 -0300 Subject: [PATCH 147/191] =?UTF-8?q?Testa=20instala=C3=A7=C3=A3o=20no=20Mac?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 1 + profile/README.md | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index b0f2218..9f5301c 100644 --- a/flake.nix +++ b/flake.nix @@ -807,6 +807,7 @@ # poetry python3Full tmate + podman ]; shellHook = '' diff --git a/profile/README.md b/profile/README.md index 7219324..6ad87e8 100644 --- a/profile/README.md +++ b/profile/README.md @@ -841,17 +841,28 @@ https://github.com/imobanco/.config-nixpkgs #### Instalando o homebrew +1) ```bash -NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/fc8acb0828f89f8aa83162000db1b49de71fa5d8/install.sh)" \ +export NONINTERACTIVE=1 \ +&& /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/fc8acb0828f89f8aa83162000db1b49de71fa5d8/install.sh)" \ && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME"/.zprofile ``` +2) +```bash +export NONINTERACTIVE=1 \ +&& COMMIT_SHA256=fc8acb0828f89f8aa83162000db1b49de71fa5d8 \ +&& /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/$COMMIT_SHA256/install.sh)" \ +&& echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME"/.zprofile +``` + + Instalando o `hello`: ```bash brew install hello ``` -Testando o `hello` +Testando o `hello`: ```bash hello ``` From 01c5e7d38eb2ef532e3ddda9d93ca5b03a64306f Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 23 Jun 2023 12:00:06 -0300 Subject: [PATCH 148/191] =?UTF-8?q?Testa=20instala=C3=A7=C3=A3o=20no=20Mac?= =?UTF-8?q?,=20simplifica=20instala=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/profile/README.md b/profile/README.md index 6ad87e8..2bea704 100644 --- a/profile/README.md +++ b/profile/README.md @@ -841,20 +841,17 @@ https://github.com/imobanco/.config-nixpkgs #### Instalando o homebrew -1) -```bash -export NONINTERACTIVE=1 \ -&& /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/fc8acb0828f89f8aa83162000db1b49de71fa5d8/install.sh)" \ -&& echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME"/.zprofile -``` -2) ```bash -export NONINTERACTIVE=1 \ -&& COMMIT_SHA256=fc8acb0828f89f8aa83162000db1b49de71fa5d8 \ +COMMIT_SHA256=fc8acb0828f89f8aa83162000db1b49de71fa5d8 \ && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/$COMMIT_SHA256/install.sh)" \ && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME"/.zprofile ``` +Refs.: +- https://brew.sh/ +- https://github.com/orgs/Homebrew/discussions/3199 +- https://github.com/Homebrew/brew/issues/3428 +- https://stackoverflow.com/questions/75140626/installing-brew-hangs-in-docker-build Instalando o `hello`: @@ -874,15 +871,16 @@ brew uninstall hello #### Mac and nix +1) ```bash NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ && echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile ``` -Feche o terminal, instalador obriga. +2) Feche o terminal, o instalador "obriga". -Abra o terminal: +3) Abra o terminal: ```bash nix profile install nixpkgs#hello nixpkgs#tmate ``` From c3bb6d2d52c3e7a9d855e603e4d223b45bf8cefc Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 23 Jun 2023 12:42:03 -0300 Subject: [PATCH 149/191] Simplifica comandos --- profile/README.md | 58 +++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/profile/README.md b/profile/README.md index 2bea704..63c4f0f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -142,7 +142,8 @@ sudo useradd -m -s "$SHELL" "$NOME_DO_SEU_USER" sudo usermod --append --groups sudo "$NOME_DO_SEU_USER" sudo passwd "$NOME_DO_SEU_USER" -# TODO: talvez o snipet abaixo possa ser mergido com esse aproveitando que se sabe o "home do user" pois se tem o nome do user +# TODO: talvez o snipet abaixo possa ser mergido com esse aproveitando +# que se sabe o "home do user" pois se tem o nome do user ``` @@ -183,12 +184,6 @@ $(test $(stat -c %u:%g /nix/store) = $(id -u):$(id -g)) \ || sudo chown $(id -u):$(id -g) /nix/store/kyk7f08qqmn86p0f0wzkr1rqjakbg418-shadow-4.11.1/bin/new{u,g}idmap ``` -```bash -test $(stat -c %u:%g /nix) = 0:0 -``` - - - ```bash podman info 1> /dev/null 2> /dev/null \ @@ -201,39 +196,6 @@ Notas: - [Allow gc-ing with a rootless daemon](https://github.com/NixOS/nix/pull/5380) - [Extra-secure store objects that Nix cannot modify](https://github.com/NixOS/nix/issues/7471) -Parte old) - -Abra o terminal novamente e cole o código abaixo: -```bash -sudo \ -su \ -"$USER" \ -<<'COMMANDS' -NAME_SHELL=$(basename $SHELL) \ -&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ -&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ -&& echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/.profile \ -&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile \ -&& . "$HOME"/."$NAME_SHELL"rc \ -&& . "$HOME"/.profile \ -&& nix flake --version \ -&& nix --extra-experimental-features 'nix-command flakes' profile install -vvv nixpkgs#direnv nixpkgs#git \ -&& . "$HOME"/."$NAME_SHELL"rc \ -&& . "$HOME"/.profile -COMMANDS -``` - - -nix run nixpkgs#nix-info -- -m - - - system: `"x86_64-linux"` - - host os: `Linux 5.15.0-58-generic, Ubuntu, 22.04.1 LTS (Jammy Jellyfish), nobuild` - - multi-user?: `yes` - - sandbox: `yes` - - version: `nix-env (Nix) 2.10.2` - - channels(root): `"nixpkgs"` - - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs - ### Mac @@ -852,6 +814,8 @@ Refs.: - https://github.com/orgs/Homebrew/discussions/3199 - https://github.com/Homebrew/brew/issues/3428 - https://stackoverflow.com/questions/75140626/installing-brew-hangs-in-docker-build +- https://stackoverflow.com/a/76188907 +- https://apple.stackexchange.com/questions/458026/which-etc-zsh-related-files-are-safe-from-os-update-overwrites Instalando o `hello`: @@ -877,6 +841,11 @@ NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ && echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile ``` +Ref.: +- https://github.com/NixOS/nix/issues/3616#issuecomment-1430907248 +- https://github.com/NixOS/nix/issues/3616#issuecomment-1554690522 +- https://github.com/NixOS/nix/issues/3616#issuecomment-1557404536 + 2) Feche o terminal, o instalador "obriga". @@ -885,6 +854,15 @@ NIX_RELEASE_VERSION=2.10.2 \ nix profile install nixpkgs#hello nixpkgs#tmate ``` +4) Testando a execussão do `hello`: +```bash +hello +``` + + +##### Outros testes no Mac + + ```bash nix eval --impure --raw --expr 'builtins.currentSystem' ``` From 9c2c2ee83ff7b1647756a02bef375e9e5ea4f814 Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 23 Jun 2023 14:01:22 -0300 Subject: [PATCH 150/191] =?UTF-8?q?Refatora=20instru=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 63c4f0f..e81e46e 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1,5 +1,7 @@ # Hi there 👋 +## Clonando este repositório para desenvolvimento local + ```bash git clone git@github.com:PedroRegisPOAR/.github.git \ && cd .github \ @@ -8,7 +10,7 @@ git clone git@github.com:PedroRegisPOAR/.github.git \ ``` -1) Instalação do nix para apenas UM usuário, _single user_, que é equivalente a usar a flag `--no-daemon`. +## Instalação do nix para apenas UM usuário (apenas você utiliza a máquina), _single user_, que é equivalente a usar a flag `--no-daemon` Versão curta: para linux ```bash @@ -65,8 +67,8 @@ Basta atualizar o hash/id da instalação. -2) Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador, _multi user_, que é -equivalente a usar a flag `--daemon`. +## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador, _multi user_, que é +equivalente a usar a flag `--daemon` Versão curta: para linux From 4d8574134bc6844fb5fc429aa2f9f0e48b44c0ce Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 23 Jun 2023 14:02:50 -0300 Subject: [PATCH 151/191] =?UTF-8?q?Refatora=20instru=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index e81e46e..bede127 100644 --- a/profile/README.md +++ b/profile/README.md @@ -10,7 +10,7 @@ git clone git@github.com:PedroRegisPOAR/.github.git \ ``` -## Instalação do nix para apenas UM usuário (apenas você utiliza a máquina), _single user_, que é equivalente a usar a flag `--no-daemon` +## Instalação do nix para apenas UM usuário (apenas você utiliza a máquina) Versão curta: para linux ```bash @@ -67,8 +67,7 @@ Basta atualizar o hash/id da instalação. -## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador, _multi user_, que é -equivalente a usar a flag `--daemon` +## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador Versão curta: para linux From 145e7fcbe065759e578598e803f113d4ec182974 Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 23 Jun 2023 14:53:27 -0300 Subject: [PATCH 152/191] =?UTF-8?q?Refatora=20instru=C3=A7=C3=B5es,=20meno?= =?UTF-8?q?res=20t=C3=ADtulos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/profile/README.md b/profile/README.md index bede127..7ad91fd 100644 --- a/profile/README.md +++ b/profile/README.md @@ -70,11 +70,15 @@ Basta atualizar o hash/id da instalação. ## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador -Versão curta: para linux +Versão curta: ```bash wget -qO- http://ix.io/4w9r | sh ``` +Notas: +- [Allow gc-ing with a rootless daemon](https://github.com/NixOS/nix/pull/5380) +- [Extra-secure store objects that Nix cannot modify](https://github.com/NixOS/nix/issues/7471) +
Versão longa (click para expandir): @@ -130,10 +134,11 @@ Basta atualizar o hash/id da instalação.
+### Para MULTIPLOS usuários compartilhando o mesmo computador -Cria um usuário com: +O script abaixo cria um usuário com: - `$HOME`; -- participante do grupo `sudo`, ou seja, equivalente a permissão `root`; +- membro do grupo `sudo`, ou seja, equivalente a permissão `root`; - configura uma senha para esse user. ```bash @@ -193,9 +198,6 @@ podman info 1> /dev/null 2> /dev/null \ Feche o terminal. -Notas: -- [Allow gc-ing with a rootless daemon](https://github.com/NixOS/nix/pull/5380) -- [Extra-secure store objects that Nix cannot modify](https://github.com/NixOS/nix/issues/7471) ### Mac From 4c64cda3f699f727ef8040d0545438d50f8dd093 Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Mon, 26 Jun 2023 12:04:41 -0300 Subject: [PATCH 153/191] =?UTF-8?q?WIP:=20instru=C3=A7=C3=B5es=20de=20desi?= =?UTF-8?q?nstala=C3=A7=C3=A3o=20do=20Mac?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/profile/README.md b/profile/README.md index 7ad91fd..bbeee21 100644 --- a/profile/README.md +++ b/profile/README.md @@ -239,6 +239,69 @@ Basta atualizar o hash/id da instalação.
+#### Desinstalando Mac + +> Infelizmente não é algo muito "automágico". + +1) +```bash +# Customisado, adaptado do manual +cat /etc/zshrc | sed -i "/# Nix/,/# End Nix/d" +cat /etc/bashrc | sed -i "/# Nix/,/# End Nix/d" +cat /etc/bash.bashrc | sed -i "/# Nix/,/# End Nix/d" +``` + +2) +```bash +sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist +sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist +sudo launchctl unload /Library/LaunchDaemons/org.nixos.darwin-store.plist +sudo rm /Library/LaunchDaemons/org.nixos.darwin-store.plist +``` + +3) +```bash +# Para debugar/verificar se os users existem +# for u in $(sudo dscl . -list /Users | grep _nixbld);do echo $u; done +sudo dscl . -delete /Groups/nixbld +for u in $(sudo dscl . -list /Users | grep _nixbld); do sudo dscl . -delete /Users/$u; done +``` + +4) Tem que ser, ao menos por hora, feito manualmente: +```bash +sudo vifs +``` + +> Edit fstab using `sudo vifs` to remove the line mounting the Nix Store volume on /nix, which +> looks like `UUID= /nix apfs rw,noauto,nobrowse,suid,owners` or `LABEL=Nix\040Store /nix apfs rw,nobrowse`. +> This will prevent automatic mounting of the Nix Store volume. + +5) +```bash +# Customisado, adaptado do manual +([ $(grep nix /etc/synthetic.conf -c) = $(wc -l < /etc/synthetic.conf) ] && sudo rm -v /etc/synthetic.conf) || echo 'Verifique o conteúdo do arquivo /etc/synthetic.conf' +``` + +6) +```bash +# ls -al /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels + +sudo rm -rf /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels +``` + +7) +```bash +# sudo diskutil apfs list | grep 'Nix Store' -B2 -A4 +sudo diskutil apfs deleteVolume /nix +``` + + +Refs.: +- https://nixos.org/manual/nix/stable/installation/uninstall.html#macos +- https://github.com/NixOS/nix/issues/458 +- https://github.com/NixOS/nix/issues/6787 + + ## Parte 2, home-manager + nix Existem 3 tipos de configurações, descritos nas próximas seções: apenas CLI, apenas CLI slim, e com From b44abd6b7bf28bdca7db9de0dd61b72e23091f40 Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Mon, 26 Jun 2023 16:21:26 -0300 Subject: [PATCH 154/191] Adiciona link com TODO --- profile/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/profile/README.md b/profile/README.md index bbeee21..71f3cf0 100644 --- a/profile/README.md +++ b/profile/README.md @@ -281,6 +281,7 @@ sudo vifs # Customisado, adaptado do manual ([ $(grep nix /etc/synthetic.conf -c) = $(wc -l < /etc/synthetic.conf) ] && sudo rm -v /etc/synthetic.conf) || echo 'Verifique o conteúdo do arquivo /etc/synthetic.conf' ``` +TODO: https://www.reddit.com/r/Nix/comments/vwwfqb/uninstall_nix_on_macos_cant_delete_nix_store/ 6) ```bash From 9377e7440f4bad99a006cdc7eec98f90993e4c04 Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Mon, 26 Jun 2023 16:25:56 -0300 Subject: [PATCH 155/191] Adiciona link com TODO --- profile/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/profile/README.md b/profile/README.md index 71f3cf0..16e03ac 100644 --- a/profile/README.md +++ b/profile/README.md @@ -301,6 +301,7 @@ Refs.: - https://nixos.org/manual/nix/stable/installation/uninstall.html#macos - https://github.com/NixOS/nix/issues/458 - https://github.com/NixOS/nix/issues/6787 +- https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551552972 voltado para flakes ## Parte 2, home-manager + nix From bf2177c7a16d4ea945dca72ba0bf4e43dad3500f Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 29 Jun 2023 15:08:18 -0300 Subject: [PATCH 156/191] =?UTF-8?q?Avan=C3=A7a=20no=20script=20de=20disins?= =?UTF-8?q?tala=C3=A7=C3=A3o=20do=20nix=20no=20Mac?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 71 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 8 deletions(-) diff --git a/profile/README.md b/profile/README.md index 16e03ac..aaa0595 100644 --- a/profile/README.md +++ b/profile/README.md @@ -222,6 +222,8 @@ nix profile install nixpkgs#{direnv,git,direnv,curl,wget} NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ && echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile + +nix registry pin github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c ``` Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. @@ -239,24 +241,28 @@ Basta atualizar o hash/id da instalação. -#### Desinstalando Mac +#### Desinstalando nix no Mac > Infelizmente não é algo muito "automágico". 1) ```bash # Customisado, adaptado do manual -cat /etc/zshrc | sed -i "/# Nix/,/# End Nix/d" -cat /etc/bashrc | sed -i "/# Nix/,/# End Nix/d" -cat /etc/bash.bashrc | sed -i "/# Nix/,/# End Nix/d" +# cat /etc/zshrc | sed "/# Nix/,/# End Nix/d" +# cat /etc/bashrc | sed "/# Nix/,/# End Nix/d" +# cat /etc/bash.bashrc | sed "/# Nix/,/# End Nix/d" + +sed -i "/# Nix/,/# End Nix/d" /etc/zshrc +sed -i "/# Nix/,/# End Nix/d" /etc/bashrc +sed -i "/# Nix/,/# End Nix/d" /etc/bash.bashrc ``` 2) ```bash sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist -sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist +sudo rm -v /Library/LaunchDaemons/org.nixos.nix-daemon.plist sudo launchctl unload /Library/LaunchDaemons/org.nixos.darwin-store.plist -sudo rm /Library/LaunchDaemons/org.nixos.darwin-store.plist +sudo rm -v /Library/LaunchDaemons/org.nixos.darwin-store.plist ``` 3) @@ -281,13 +287,20 @@ sudo vifs # Customisado, adaptado do manual ([ $(grep nix /etc/synthetic.conf -c) = $(wc -l < /etc/synthetic.conf) ] && sudo rm -v /etc/synthetic.conf) || echo 'Verifique o conteúdo do arquivo /etc/synthetic.conf' ``` + +```bash +# sed '/nix/d' /etc/synthetic.conf +sudo sed -i '/nix/d' /etc/synthetic.conf +``` TODO: https://www.reddit.com/r/Nix/comments/vwwfqb/uninstall_nix_on_macos_cant_delete_nix_store/ 6) ```bash -# ls -al /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels +# ls -al /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr \ +# /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels -sudo rm -rf /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels +sudo rm -frv /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr \ +/var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ``` 7) @@ -304,6 +317,48 @@ Refs.: - https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551552972 voltado para flakes +#### Script mergido + +TODO: +```bash +diskutil apfs list -plist | plutil -convert json -o - - +``` +Refs.: +- https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 + +```bash +sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/zshrc \ +&& sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/bashrc \ +&& sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/bash.bashrc + +sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist \ +&& sudo rm -v /Library/LaunchDaemons/org.nixos.nix-daemon.plist \ +&& sudo launchctl unload /Library/LaunchDaemons/org.nixos.darwin-store.plist \ +&& sudo rm -v /Library/LaunchDaemons/org.nixos.darwin-store.plist + +sudo dscl . -delete /Groups/nixbld +for u in $(sudo dscl . -list /Users | grep _nixbld); do sudo dscl . -delete /Users/$u; done + +sudo sed -i '' '/nix/d' /etc/synthetic.conf \ +&& sudo rm -frv /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr \ + /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels \ + /etc/bashrc.backup-before-nix \ + /etc/zshrc.backup-before-nix \ +&& sudo diskutil apfs deleteVolume /nix + +sudo reboot +``` + +Checando que o volume não existe: +```bash +sudo diskutil apfs list | grep 'Nix Store' -B2 -A4 +``` + +```bash +ls -al /nix +``` + + ## Parte 2, home-manager + nix Existem 3 tipos de configurações, descritos nas próximas seções: apenas CLI, apenas CLI slim, e com From c9f5e1283e29e495df3dfef1d81befbb25c4893b Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 29 Jun 2023 17:27:17 -0300 Subject: [PATCH 157/191] WIP --- profile/README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index aaa0595..b0c1022 100644 --- a/profile/README.md +++ b/profile/README.md @@ -337,11 +337,16 @@ sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist \ && sudo rm -v /Library/LaunchDaemons/org.nixos.darwin-store.plist sudo dscl . -delete /Groups/nixbld -for u in $(sudo dscl . -list /Users | grep _nixbld); do sudo dscl . -delete /Users/$u; done +for u in $(sudo dscl . -list /Users | grep _nixbld); do echo $u && sudo dscl . -delete /Users/$u; done sudo sed -i '' '/nix/d' /etc/synthetic.conf \ -&& sudo rm -frv /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr \ - /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels \ +&& sudo rm -frv /etc/nix \ + /var/root/.nix-profile \ + /var/root/.nix-defexpr \ + /var/root/.nix-channels \ + ~/.nix-profile \ + ~/.nix-defexpr \ + ~/.nix-channels \ /etc/bashrc.backup-before-nix \ /etc/zshrc.backup-before-nix \ && sudo diskutil apfs deleteVolume /nix From 1be12219b0b962d7e34402f743aece284dccf7af Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 30 Jun 2023 15:37:58 -0300 Subject: [PATCH 158/191] =?UTF-8?q?WIP:=20avan=C3=A7os=20com=20diskutil=20?= =?UTF-8?q?apfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/profile/README.md b/profile/README.md index b0c1022..cdf0a05 100644 --- a/profile/README.md +++ b/profile/README.md @@ -212,7 +212,13 @@ curl -L http://ix.io/4vEW | sh Após abrir o terminal: ```bash -nix profile install nixpkgs#{direnv,git,direnv,curl,wget} +nix registry pin github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c +``` + + +Testando a instalação: +```bash +nix profile install nixpkgs#{curl,direnv,git,jq,wget} ```
@@ -222,8 +228,6 @@ nix profile install nixpkgs#{direnv,git,direnv,curl,wget} NIX_RELEASE_VERSION=2.10.2 \ && curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ && echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile - -nix registry pin github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c ``` Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. @@ -319,12 +323,13 @@ Refs.: #### Script mergido -TODO: +TODO: como pegar o identificador único do disco? Usar o `jq`? ```bash -diskutil apfs list -plist | plutil -convert json -o - - +diskutil info -plist /nix | plutil -convert json -o - - | jq '."RecoveryDeviceIdentifier"' ``` Refs.: - https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 +- https://apple.stackexchange.com/a/319977 ```bash sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/zshrc \ @@ -340,15 +345,16 @@ sudo dscl . -delete /Groups/nixbld for u in $(sudo dscl . -list /Users | grep _nixbld); do echo $u && sudo dscl . -delete /Users/$u; done sudo sed -i '' '/nix/d' /etc/synthetic.conf \ -&& sudo rm -frv /etc/nix \ - /var/root/.nix-profile \ - /var/root/.nix-defexpr \ - /var/root/.nix-channels \ - ~/.nix-profile \ - ~/.nix-defexpr \ - ~/.nix-channels \ - /etc/bashrc.backup-before-nix \ - /etc/zshrc.backup-before-nix \ +&& sudo rm -frv \ + /etc/bashrc.backup-before-nix \ + /etc/nix \ + /etc/zshrc.backup-before-nix \ + /var/root/.nix-channels \ + /var/root/.nix-defexpr \ + /var/root/.nix-profile \ + ~/.nix-channels \ + ~/.nix-defexpr \ + ~/.nix-profile \ && sudo diskutil apfs deleteVolume /nix sudo reboot From 5cbee6e6896ecb10426b7460a20295bbff022b52 Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 30 Jun 2023 17:11:04 -0300 Subject: [PATCH 159/191] =?UTF-8?q?WIP:=20avan=C3=A7os=20com=20diskutil=20?= =?UTF-8?q?apfs=20e=20jq?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/profile/README.md b/profile/README.md index cdf0a05..ab4aac7 100644 --- a/profile/README.md +++ b/profile/README.md @@ -323,15 +323,17 @@ Refs.: #### Script mergido -TODO: como pegar o identificador único do disco? Usar o `jq`? -```bash -diskutil info -plist /nix | plutil -convert json -o - - | jq '."RecoveryDeviceIdentifier"' -``` -Refs.: -- https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 -- https://apple.stackexchange.com/a/319977 + + + ```bash +jq --version 1> /dev/null 2> /dev/null || nix profile install nixpkgs#jq + +VOLUME_NIX_DEVICE_IDENTIFIER=$(diskutil info -plist /nix | plutil -convert json -o - - | jq -r '."DeviceIdentifier"') + +echo $VOLUME_NIX_DEVICE_IDENTIFIER + sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/zshrc \ && sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/bashrc \ && sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/bash.bashrc @@ -342,10 +344,10 @@ sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist \ && sudo rm -v /Library/LaunchDaemons/org.nixos.darwin-store.plist sudo dscl . -delete /Groups/nixbld -for u in $(sudo dscl . -list /Users | grep _nixbld); do echo $u && sudo dscl . -delete /Users/$u; done sudo sed -i '' '/nix/d' /etc/synthetic.conf \ && sudo rm -frv \ + /etc/bash.bashrc.backup-before-nix \ /etc/bashrc.backup-before-nix \ /etc/nix \ /etc/zshrc.backup-before-nix \ @@ -355,9 +357,25 @@ sudo sed -i '' '/nix/d' /etc/synthetic.conf \ ~/.nix-channels \ ~/.nix-defexpr \ ~/.nix-profile \ -&& sudo diskutil apfs deleteVolume /nix +&& diskutil info -plist $VOLUME_NIX_DEVICE_IDENTIFIER 1>/dev/null 2>/dev/null \ +&& sudo diskutil apfs deleteVolume $VOLUME_NIX_DEVICE_IDENTIFIER \ +&& sudo reboot +``` -sudo reboot + +Como pegar o identificador único do disco? Usar o `jq`? +```bash +diskutil info -plist /nix | plutil -convert json -o - - | jq -r '."DeviceIdentifier"' +``` +Refs.: +- https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 +- https://apple.stackexchange.com/a/319977 + + +Não usado: +```bash +# for u in $(sudo dscl . -list /Users | grep _nixbld); do echo $u && sudo dscl . -delete /Users/$u; done +# sudo diskutil apfs deleteVolume /nix ``` Checando que o volume não existe: From e72ea91d884c57a4fc886a434030d119e63390bf Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Fri, 30 Jun 2023 17:26:59 -0300 Subject: [PATCH 160/191] =?UTF-8?q?Refatora=20instru=C3=A7=C3=B5es,=20func?= =?UTF-8?q?ionou=20algumas=20vezes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 106 ++++++---------------------------------------- 1 file changed, 13 insertions(+), 93 deletions(-) diff --git a/profile/README.md b/profile/README.md index ab4aac7..6bf8c04 100644 --- a/profile/README.md +++ b/profile/README.md @@ -247,86 +247,10 @@ Basta atualizar o hash/id da instalação. #### Desinstalando nix no Mac -> Infelizmente não é algo muito "automágico". - -1) -```bash -# Customisado, adaptado do manual -# cat /etc/zshrc | sed "/# Nix/,/# End Nix/d" -# cat /etc/bashrc | sed "/# Nix/,/# End Nix/d" -# cat /etc/bash.bashrc | sed "/# Nix/,/# End Nix/d" - -sed -i "/# Nix/,/# End Nix/d" /etc/zshrc -sed -i "/# Nix/,/# End Nix/d" /etc/bashrc -sed -i "/# Nix/,/# End Nix/d" /etc/bash.bashrc -``` - -2) -```bash -sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist -sudo rm -v /Library/LaunchDaemons/org.nixos.nix-daemon.plist -sudo launchctl unload /Library/LaunchDaemons/org.nixos.darwin-store.plist -sudo rm -v /Library/LaunchDaemons/org.nixos.darwin-store.plist -``` - -3) -```bash -# Para debugar/verificar se os users existem -# for u in $(sudo dscl . -list /Users | grep _nixbld);do echo $u; done -sudo dscl . -delete /Groups/nixbld -for u in $(sudo dscl . -list /Users | grep _nixbld); do sudo dscl . -delete /Users/$u; done -``` - -4) Tem que ser, ao menos por hora, feito manualmente: -```bash -sudo vifs -``` - -> Edit fstab using `sudo vifs` to remove the line mounting the Nix Store volume on /nix, which -> looks like `UUID= /nix apfs rw,noauto,nobrowse,suid,owners` or `LABEL=Nix\040Store /nix apfs rw,nobrowse`. -> This will prevent automatic mounting of the Nix Store volume. - -5) -```bash -# Customisado, adaptado do manual -([ $(grep nix /etc/synthetic.conf -c) = $(wc -l < /etc/synthetic.conf) ] && sudo rm -v /etc/synthetic.conf) || echo 'Verifique o conteúdo do arquivo /etc/synthetic.conf' -``` - -```bash -# sed '/nix/d' /etc/synthetic.conf -sudo sed -i '/nix/d' /etc/synthetic.conf -``` -TODO: https://www.reddit.com/r/Nix/comments/vwwfqb/uninstall_nix_on_macos_cant_delete_nix_store/ - -6) -```bash -# ls -al /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr \ -# /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels - -sudo rm -frv /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr \ -/var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels -``` - -7) -```bash -# sudo diskutil apfs list | grep 'Nix Store' -B2 -A4 -sudo diskutil apfs deleteVolume /nix -``` - - -Refs.: -- https://nixos.org/manual/nix/stable/installation/uninstall.html#macos -- https://github.com/NixOS/nix/issues/458 -- https://github.com/NixOS/nix/issues/6787 -- https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551552972 voltado para flakes - - -#### Script mergido - - - +> Infelizmente não é algo "automágico". +1) Script aglutinado ```bash jq --version 1> /dev/null 2> /dev/null || nix profile install nixpkgs#jq @@ -358,37 +282,33 @@ sudo sed -i '' '/nix/d' /etc/synthetic.conf \ ~/.nix-defexpr \ ~/.nix-profile \ && diskutil info -plist $VOLUME_NIX_DEVICE_IDENTIFIER 1>/dev/null 2>/dev/null \ -&& sudo diskutil apfs deleteVolume $VOLUME_NIX_DEVICE_IDENTIFIER \ -&& sudo reboot -``` - - -Como pegar o identificador único do disco? Usar o `jq`? -```bash -diskutil info -plist /nix | plutil -convert json -o - - | jq -r '."DeviceIdentifier"' +&& sudo diskutil apfs deleteVolume $VOLUME_NIX_DEVICE_IDENTIFIER ``` Refs.: +- https://nixos.org/manual/nix/stable/installation/uninstall.html#macos +- https://github.com/NixOS/nix/issues/458 +- https://github.com/NixOS/nix/issues/6787 +- https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551552972 voltado para flakes - https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 - https://apple.stackexchange.com/a/319977 -Não usado: +2) ```bash -# for u in $(sudo dscl . -list /Users | grep _nixbld); do echo $u && sudo dscl . -delete /Users/$u; done -# sudo diskutil apfs deleteVolume /nix +sudo reboot ``` -Checando que o volume não existe: + +Após o reboot checar que o volume não existe: ```bash sudo diskutil apfs list | grep 'Nix Store' -B2 -A4 -``` -```bash ls -al /nix ``` -## Parte 2, home-manager + nix + +## Parte 2, home-manager + nix, apenas GNU/Linux Existem 3 tipos de configurações, descritos nas próximas seções: apenas CLI, apenas CLI slim, e com programas com interface gráfica. From 0e3bf1d9e2396bfb5caf961ecef6d52b75f6161b Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 2 Jul 2023 22:04:04 -0300 Subject: [PATCH 161/191] Adiciona link sobre dscl --- profile/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/profile/README.md b/profile/README.md index 6bf8c04..0f5c9af 100644 --- a/profile/README.md +++ b/profile/README.md @@ -291,6 +291,7 @@ Refs.: - https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551552972 voltado para flakes - https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 - https://apple.stackexchange.com/a/319977 +- https://fortechmenot.wordpress.com/2015/01/15/disabling-logins-for-mac-os-x-users/ 2) From f03dbe948bbd547b193e651b1494b13fca4ba365 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 2 Jul 2023 22:51:32 -0300 Subject: [PATCH 162/191] Adiciona link sobre volumes no Mac --- profile/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/profile/README.md b/profile/README.md index 0f5c9af..c6d6cd6 100644 --- a/profile/README.md +++ b/profile/README.md @@ -292,6 +292,7 @@ Refs.: - https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 - https://apple.stackexchange.com/a/319977 - https://fortechmenot.wordpress.com/2015/01/15/disabling-logins-for-mac-os-x-users/ +- https://apple.stackexchange.com/questions/396301/finding-volume-label-and-understanding-the-apfs-partition 2) From 94f10b1d77eed856f1bd3ef33880aed28731d7b1 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 13 Jul 2023 18:50:14 -0300 Subject: [PATCH 163/191] registry.nixpkgs.flake = nixpkgs; --- templates/start-slim-config/flake.nix | 5 +++-- templates/start-slim-config/home.nix | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 3e92edb..d4ec88b 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -25,7 +25,7 @@ modules = [ # https://discourse.nixos.org/t/flakes-error-error-attribute-outpath-missing/18044/2 - ({...}: { nix.registry.nixpkgs.flake = nixpkgs; }) + # ({...}: { nix.registry.nixpkgs.flake = nixpkgs; }) { home = { inherit username; @@ -39,6 +39,7 @@ # TODO: how to: Optionally use extraSpecialArgs # to pass through arguments to home.nix + extraSpecialArgs = { nixpkgs = nixpkgs; }; }; devShells.x86_64-linux.default = pkgs.mkShell { @@ -48,7 +49,7 @@ curl gnumake patchelf - poetry + # poetry python3Full tmate ]; diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index f8967b8..c3f896c 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, nixpkgs, ... }: { @@ -486,6 +486,8 @@ experimental-features = nix-command flakes ''; + registry.nixpkgs.flake = nixpkgs; + settings = { # use-sandbox = true; show-trace = false; From 0d2a066601b09a19bc186bc33ce48eeba540d8cc Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 13 Jul 2023 19:49:16 -0300 Subject: [PATCH 164/191] registry.nixpkgs.flake = nixpkgs; + sessionVariables.NIX_PATH = "nixpkgs=${pkgs.outPath}"; --- templates/start-slim-config/flake.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index d4ec88b..34bf73a 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -31,6 +31,9 @@ inherit username; homeDirectory = "/home/${username}"; # TODO: esse caminho muda no Mac! stateVersion = "22.11"; + # https://discourse.nixos.org/t/correct-way-to-use-nixpkgs-in-nix-shell-on-flake-based-system-without-channels/19360/3 + # sessionVariables.NIX_PATH = "nixpkgs=nixpkgs=flake:?"; + sessionVariables.NIX_PATH = "nixpkgs=${pkgs.outPath}"; }; programs.home-manager.enable = true; } From 7abac2b97373e3ba14296751bd515a0b4895f562 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 13 Jul 2023 20:09:40 -0300 Subject: [PATCH 165/191] registry.nixpkgs.flake = nixpkgs; + sessionVariables.NIX_PATH = "nixpkgs=${nixpkgs.outPath}"; --- templates/start-slim-config/flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 34bf73a..1e8f433 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -33,7 +33,7 @@ stateVersion = "22.11"; # https://discourse.nixos.org/t/correct-way-to-use-nixpkgs-in-nix-shell-on-flake-based-system-without-channels/19360/3 # sessionVariables.NIX_PATH = "nixpkgs=nixpkgs=flake:?"; - sessionVariables.NIX_PATH = "nixpkgs=${pkgs.outPath}"; + sessionVariables.NIX_PATH = "nixpkgs=${nixpkgs.outPath}"; }; programs.home-manager.enable = true; } From fd143d2b9ba9bb997381fb99b7d6fc0ea56019f7 Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 13 Jul 2023 22:42:04 -0300 Subject: [PATCH 166/191] =?UTF-8?q?Melhora=20script=20de=20instala=C3=A7?= =?UTF-8?q?=C3=A3o,=20commita=20estado=20inicial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profile/README.md b/profile/README.md index c6d6cd6..774687b 100644 --- a/profile/README.md +++ b/profile/README.md @@ -320,7 +320,7 @@ programas com interface gráfica. Versão curta: ```bash -wget -qO- http://ix.io/4udG | sh +wget -qO- http://ix.io/4Axd | sh ``` @@ -395,7 +395,8 @@ bash <<-EOF && git add . \ && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ && git status \ - && git add . + && git add . \ + && git commit -m 'First nix home-manager commit from installer' echo "$FLAKE_ATTR" # TODO: From 2acb98bcaabacc46352085b78a037d944f596551 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 17 Jul 2023 07:59:21 -0300 Subject: [PATCH 167/191] WIP --- profile/README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 774687b..c0ea7e3 100644 --- a/profile/README.md +++ b/profile/README.md @@ -65,7 +65,47 @@ Basta atualizar o hash/id da instalação.
+### Experimental, nix estaticamente compilado, usando /nix +```bash +wget -qO- http://ix.io/4AL6 | sh \ +&& . "$HOME"/."$(basename $SHELL)"rc \ +&& nix flake --version +``` + +```bash +test -d /nix || (sudo mkdir -pv -m 0755 /nix/var/nix && sudo -k chown -Rv "$USER": /nix); \ +test $(stat -c %a /nix) -eq 0755 || sudo -kv chmod -v 0755 /nix + +test -f nix || curl -L https://hydra.nixos.org/build/228013056/download/1/nix > nix \ +&& chmod -v +x nix \ +&& ./nix registry pin nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ +&& ./nix \ +profile \ +install \ +nixpkgs#busybox \ +--option experimental-features 'nix-command flakes' + +busybox mkdir -pv "$HOME"/.local/bin \ +&& export PATH="$HOME"/.local/bin:"$PATH" \ +&& busybox mv -v nix "$HOME"/.local/bin \ +&& busybox mkdir -pv "$HOME"/.config/nix \ +&& busybox echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf \ +&& nix flake --version + +nix \ +profile \ +remove \ +$(nix eval --raw nixpkgs#busybox) +``` + +```bash +# https://github.com/NixOS/nix/issues/6976 +URL=https://hydra.nixos.org/job/nix/master/buildStatic.x86_64-linux/latest +LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD="$(curl $URL | grep '"https://hydra.nixos.org/build/' | cut -d'/' -f5 | cut -d'"' -f1)" + +echo $LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD +``` ## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador @@ -320,7 +360,7 @@ programas com interface gráfica. Versão curta: ```bash -wget -qO- http://ix.io/4Axd | sh +wget -qO- http://ix.io/4AKW | sh ``` @@ -360,7 +400,7 @@ BASE_FLAKE_URI='github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c#' # --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ # --option extra-substituters "s3://playing-bucket-nix-cache-test" \ -time \ +# time \ nix \ --extra-experimental-features 'nix-command flakes' \ --option eval-cache false \ @@ -944,7 +984,8 @@ nix eval --impure --raw --expr 'builtins.currentSystem' ```bash -nix build --no-link --print-build-logs --rebuild nixpkgs#hello +nix build --no-link --print-build-logs nixpkgs#hello \ +&& nix build --no-link --print-build-logs --rebuild nixpkgs#hello ``` ```bash From 7016f19d1641cd1caea6e5262f4e35d29a5ca55c Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 18 Jul 2023 09:50:27 -0300 Subject: [PATCH 168/191] /Habilita less como paginador --- templates/start-slim-config/home.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index c3f896c..d83f1a2 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -503,11 +503,17 @@ }; }; + # since we set PAGER to this above, make sure it's installed + programs.less.enable = true; + # programs.less.envVariables.PAGER = "foo-bar"; + nixpkgs.config = { allowBroken = false; allowUnfree = true; # TODO: test it # android_sdk.accept_license = true; + + # allowUnfreePredicate = (pkg: true); }; services.systembus-notify.enable = true; @@ -583,6 +589,8 @@ # ZSH_AUTOSUGGEST_MANUAL_REBIND="true"; # PROMPT="|%F{153}%n@%m%f|%F{174}%1~%f> "; + # PAGER = "less"; + LANG = "en_US.utf8"; # fc-match list FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; From 7dfd6e8a390669c57046239ded9962f8a69706b6 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 18 Jul 2023 09:51:09 -0300 Subject: [PATCH 169/191] Aumenta para 1 ano tarball-ttl --- templates/start-slim-config/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index d83f1a2..976ad6e 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -495,7 +495,7 @@ keep-outputs = true; keep-derivations = true; - tarball-ttl = 60 * 60 * 24 * 7 * 4; # = 2419200 = one month + tarball-ttl = 60 * 60 * 24 * 7 * 4 * 12; # = 2419200 * 12 = 12 months # readOnlyStore = true; # trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= From ddac8abc0628c5df3eadd14829217985c11204c2 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 18 Jul 2023 09:52:26 -0300 Subject: [PATCH 170/191] Adds TODO --- templates/start-slim-config/home.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 976ad6e..7b4b29e 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -503,6 +503,7 @@ }; }; + # TODO: terminar de testar # since we set PAGER to this above, make sure it's installed programs.less.enable = true; # programs.less.envVariables.PAGER = "foo-bar"; From 4eae65c63a6d3fd436c6a54b4fd26c927daea3ce Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 18 Jul 2023 10:34:25 -0300 Subject: [PATCH 171/191] Adds CUSTOM_ENVIROMENT_VARIABLE --- templates/start-slim-config/home.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index 7b4b29e..cc314eb 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -592,6 +592,8 @@ # PAGER = "less"; + CUSTOM_ENVIROMENT_VARIABLE = "Foo-101-Bar"; + LANG = "en_US.utf8"; # fc-match list FONTCONFIG_FILE = "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; From 0060cc3d8da8ffe53f6a589e7f7869f2bbebdfbf Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 18 Jul 2023 13:57:50 -0300 Subject: [PATCH 172/191] =?UTF-8?q?Mais=20modifica=C3=A7=C3=B5es=20no=20sc?= =?UTF-8?q?ript=20do=20hm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 9 ++++-- templates/start-slim-config/flake.nix | 46 ++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/profile/README.md b/profile/README.md index c0ea7e3..0cd03fe 100644 --- a/profile/README.md +++ b/profile/README.md @@ -65,7 +65,7 @@ Basta atualizar o hash/id da instalação. -### Experimental, nix estaticamente compilado, usando /nix +### Quebrado! Experimental, nix estaticamente compilado, usando /nix ```bash wget -qO- http://ix.io/4AL6 | sh \ @@ -362,7 +362,8 @@ Versão curta: ```bash wget -qO- http://ix.io/4AKW | sh ``` - +http://ix.io/4ATD +http://ix.io/4ATX
Versão longa (click para expandir): @@ -433,7 +434,9 @@ bash <<-EOF && git init \ && git status \ && git add . \ - && nix flake update --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ + && nix flake lock \ + --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ + --override-input home-manager github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc \ && git status \ && git add . \ && git commit -m 'First nix home-manager commit from installer' diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 1e8f433..ee106f0 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -2,12 +2,47 @@ description = "Home Manager configuration"; inputs = { - # Specify the source of Home Manager and Nixpkgs - # nix flake metadata github:nix-community/home-manager/release-22.11 - home-manager.url = "github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc"; + /* + Specify the source of Home Manager and Nixpkgs + nix flake metadata github:nix-community/home-manager/release-22.11 - # nix flake metadata github:nixos/nixpkgs/release-22.11 - nixpkgs.url = "github:nixos/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c"; + # nix \ + # flake \ + # update \ + # --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') + + # nix \ + # flake \ + # update \ + # --override-input home-manager github:nix-community/home-manager/$(nix eval --impure --raw --expr '(builtins.getFlake "github:nix-community/home-manager/release-23.05").rev') + + # nix \ + # flake \ + # update \ + # --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') + + nix flake update \ + --override-input home-manager github:nix-community/home-manager/$(nix eval --impure --raw --expr '(builtins.getFlake "github:nix-community/home-manager/release-23.05").rev') \ + --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') + + # 22.11 + nix flake lock \ + --override-input nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ + --override-input home-manager github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc + + # https://channels.nix.gsc.io/nixos-22.11/history + nix flake lock \ + --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ + --override-input home-manager github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc + + nix flake lock \ + --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') \ + --override-input home-manager github:nix-community/home-manager/$(nix eval --impure --raw --expr '(builtins.getFlake "github:nix-community/home-manager/release-23.05").rev') + + */ + home-manager.url = "github:nix-community/home-manager"; + + nixpkgs.url = "github:nixos/nixpkgs"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; }; @@ -34,6 +69,7 @@ # https://discourse.nixos.org/t/correct-way-to-use-nixpkgs-in-nix-shell-on-flake-based-system-without-channels/19360/3 # sessionVariables.NIX_PATH = "nixpkgs=nixpkgs=flake:?"; sessionVariables.NIX_PATH = "nixpkgs=${nixpkgs.outPath}"; + enableNixpkgsReleaseCheck = true; }; programs.home-manager.enable = true; } From 502e5bdad52cbc5f3a81b2edd236f569e03c6a69 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 18 Jul 2023 14:41:53 -0300 Subject: [PATCH 173/191] Simplifica docstring --- templates/start-slim-config/flake.nix | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index ee106f0..776f4e8 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -6,30 +6,10 @@ Specify the source of Home Manager and Nixpkgs nix flake metadata github:nix-community/home-manager/release-22.11 - # nix \ - # flake \ - # update \ - # --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') - - # nix \ - # flake \ - # update \ - # --override-input home-manager github:nix-community/home-manager/$(nix eval --impure --raw --expr '(builtins.getFlake "github:nix-community/home-manager/release-23.05").rev') - - # nix \ - # flake \ - # update \ - # --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') - nix flake update \ --override-input home-manager github:nix-community/home-manager/$(nix eval --impure --raw --expr '(builtins.getFlake "github:nix-community/home-manager/release-23.05").rev') \ --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') - # 22.11 - nix flake lock \ - --override-input nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ - --override-input home-manager github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc - # https://channels.nix.gsc.io/nixos-22.11/history nix flake lock \ --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ From 89eeb3986f29cea9a3b84e6ab7a61482442ad95a Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 24 Jul 2023 00:05:28 -0300 Subject: [PATCH 174/191] Novos scripts --- profile/README.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/profile/README.md b/profile/README.md index 0cd03fe..c90d0d0 100644 --- a/profile/README.md +++ b/profile/README.md @@ -99,6 +99,7 @@ remove \ $(nix eval --raw nixpkgs#busybox) ``` + ```bash # https://github.com/NixOS/nix/issues/6976 URL=https://hydra.nixos.org/job/nix/master/buildStatic.x86_64-linux/latest @@ -112,7 +113,19 @@ echo $LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD Versão curta: ```bash -wget -qO- http://ix.io/4w9r | sh + +podman \ +exec \ +--interactive=true \ +--tty=true \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +bash \ +-c \ +' +wget -qO- http://ix.io/4Blu || curl -L http://ix.io/4Blu | sh +' ``` Notas: @@ -145,7 +158,8 @@ NAME_SHELL=$(basename $SHELL) \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile \ && nix flake --version \ -&& nix --extra-experimental-features 'nix-command flakes' profile install -vvv nixpkgs#direnv nixpkgs#git \ +&& nix --extra-experimental-features 'nix-command flakes' -vv registry pin nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ +&& nix --extra-experimental-features 'nix-command flakes' profile install -vv nixpkgs#direnv nixpkgs#git \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile COMMANDS @@ -360,10 +374,12 @@ programas com interface gráfica. Versão curta: ```bash -wget -qO- http://ix.io/4AKW | sh +# http://ix.io/4AKW +# http://ix.io/4ATD +wget -qO- http://ix.io/4ATX || curl -L http://ix.io/4ATX | sh ``` -http://ix.io/4ATD -http://ix.io/4ATX + +
Versão longa (click para expandir): From dfd1688a14fb4b9afb9dde9c122083aea9903921 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 24 Jul 2023 23:11:00 -0300 Subject: [PATCH 175/191] Updates commit nixpkgs hash --- flake.lock | 12 ++++++------ templates/start-slim-config/flake.nix | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 6d901c2..8109d3f 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1687171271, - "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "owner": "numtide", "repo": "flake-utils", - "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1671313200, - "narHash": "sha256-itZTrtHeDJjV696+ur0/TzkTqb5y3Eb57WRLRPK3rwA=", + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0938d73bb143f4ae037143572f11f4338c7b2d1c", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", "type": "github" }, "original": { diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 776f4e8..8e3acad 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -12,7 +12,7 @@ # https://channels.nix.gsc.io/nixos-22.11/history nix flake lock \ - --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ + --override-input nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ --override-input home-manager github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc nix flake lock \ From 81e00d3e6d7564c45764dde884c2ca6528750527 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 24 Jul 2023 23:25:13 -0300 Subject: [PATCH 176/191] Updates commit nixpkgs hash --- profile/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/profile/README.md b/profile/README.md index c90d0d0..4dda3b6 100644 --- a/profile/README.md +++ b/profile/README.md @@ -14,7 +14,7 @@ git clone git@github.com:PedroRegisPOAR/.github.git \ Versão curta: para linux ```bash -wget -qO- http://ix.io/4vCI | sh \ +wget -qO- http://ix.io/4Bqe || curl -L http://ix.io/4Bqe | sh \ && . "$HOME"/."$(basename $SHELL)"rc \ && nix flake --version ``` @@ -45,7 +45,7 @@ NAME_SHELL=$(basename $SHELL) \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile \ && nix flake --version \ -&& nix --extra-experimental-features 'nix-command flakes' -vv registry pin nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ +&& nix --extra-experimental-features 'nix-command flakes' -vv registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ && nix --extra-experimental-features 'nix-command flakes' -vv profile install nixpkgs#direnv nixpkgs#git \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile @@ -79,7 +79,7 @@ test $(stat -c %a /nix) -eq 0755 || sudo -kv chmod -v 0755 /nix test -f nix || curl -L https://hydra.nixos.org/build/228013056/download/1/nix > nix \ && chmod -v +x nix \ -&& ./nix registry pin nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ +&& ./nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ && ./nix \ profile \ install \ @@ -158,7 +158,7 @@ NAME_SHELL=$(basename $SHELL) \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile \ && nix flake --version \ -&& nix --extra-experimental-features 'nix-command flakes' -vv registry pin nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ +&& nix --extra-experimental-features 'nix-command flakes' -vv registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ && nix --extra-experimental-features 'nix-command flakes' profile install -vv nixpkgs#direnv nixpkgs#git \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile @@ -266,7 +266,7 @@ curl -L http://ix.io/4vEW | sh Após abrir o terminal: ```bash -nix registry pin github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c +nix registry pin github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b ``` @@ -376,17 +376,17 @@ Versão curta: ```bash # http://ix.io/4AKW # http://ix.io/4ATD -wget -qO- http://ix.io/4ATX || curl -L http://ix.io/4ATX | sh +wget -qO- http://ix.io/4Bqg || curl -L http://ix.io/4Bqg | sh ``` -
Versão longa (click para expandir): ```bash # Precisa das variáveis de ambiente USER e HOME # export DUMMY_USER="$(id -un)" +# TODO: checar se $USER tem alguma string, caso não pelo menos imprimir logs export DUMMY_USER="$USER" DIRECTORY_TO_CLONE=/home/"$USER"/.config/nixpkgs @@ -413,7 +413,7 @@ export DUMMY_HOSTNAME="$(hostname)" HM_ATTR_FULL_NAME='"'"$DUMMY_USER"-"$DUMMY_HOSTNAME"'"' FLAKE_ATTR="$DIRECTORY_TO_CLONE""#homeConfigurations."'\"'"$HM_ATTR_FULL_NAME"'\"'".activationPackage" -BASE_FLAKE_URI='github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c#' +BASE_FLAKE_URI='github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b#' # --option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ # --option extra-substituters "s3://playing-bucket-nix-cache-test" \ @@ -451,7 +451,7 @@ bash <<-EOF && git status \ && git add . \ && nix flake lock \ - --override-input nixpkgs github:NixOS/nixpkgs/0938d73bb143f4ae037143572f11f4338c7b2d1c \ + --override-input nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ --override-input home-manager github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc \ && git status \ && git add . \ From 05ab7b61dc7498f2f99e7ad69d2c71917cee78ae Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 25 Jul 2023 19:40:45 -0300 Subject: [PATCH 177/191] WIP --- profile/README.md | 28 ++++++++++++++--------- templates/start-slim-config/home.nix | 34 +++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/profile/README.md b/profile/README.md index 4dda3b6..77c0515 100644 --- a/profile/README.md +++ b/profile/README.md @@ -73,30 +73,36 @@ wget -qO- http://ix.io/4AL6 | sh \ && nix flake --version ``` + + ```bash test -d /nix || (sudo mkdir -pv -m 0755 /nix/var/nix && sudo -k chown -Rv "$USER": /nix); \ test $(stat -c %a /nix) -eq 0755 || sudo -kv chmod -v 0755 /nix test -f nix || curl -L https://hydra.nixos.org/build/228013056/download/1/nix > nix \ && chmod -v +x nix \ -&& ./nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ && ./nix \ -profile \ -install \ -nixpkgs#busybox \ ---option experimental-features 'nix-command flakes' + --option experimental-features 'nix-command flakes' \ + registry \ + pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ +&& FULL_PATH_FOR_BUSYBOX="$(./nix \ + --option experimental-features 'nix-command flakes' \ + build \ + --no-link \ + --print-build-logs \ + --print-out-paths \ + nixpkgs#busybox)"/bin/busybox \ +&& "$FULL_PATH_FOR_BUSYBOX" cp -v "$FULL_PATH_FOR_BUSYBOX" . \ +&& chmod -v +x busybox \ +&& busybox busybox mkdir -pv "$HOME"/.local/bin \ && export PATH="$HOME"/.local/bin:"$PATH" \ && busybox mv -v nix "$HOME"/.local/bin \ && busybox mkdir -pv "$HOME"/.config/nix \ && busybox echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf \ -&& nix flake --version - -nix \ -profile \ -remove \ -$(nix eval --raw nixpkgs#busybox) +&& nix flake --version \ +&& busybox rm -v busybox ``` diff --git a/templates/start-slim-config/home.nix b/templates/start-slim-config/home.nix index cc314eb..c74f303 100644 --- a/templates/start-slim-config/home.nix +++ b/templates/start-slim-config/home.nix @@ -278,12 +278,34 @@ '' ) - ( - writeScriptBin "nfm" '' - #! ${pkgs.runtimeShell} -e - nix flake metadata $1 --json | jq -r '.url' - '' - ) + ( + writeScriptBin "nfmn" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata nixpkgs + '' + ) + + ( + writeScriptBin "nfm" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 + '' + ) + + + ( + writeScriptBin "nfmn-j" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata nixpkgs --json | jq -r '.url' + '' + ) + + ( + writeScriptBin "nfm-j" '' + #! ${pkgs.runtimeShell} -e + nix flake metadata $1 --json | jq -r '.url' + '' + ) ( writeScriptBin "hms" '' From 55e9da0f455854a52bd0bf478e0a12b76789a530 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 25 Jul 2023 19:51:53 -0300 Subject: [PATCH 178/191] WIP --- profile/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/profile/README.md b/profile/README.md index 77c0515..d3b9b55 100644 --- a/profile/README.md +++ b/profile/README.md @@ -77,10 +77,10 @@ wget -qO- http://ix.io/4AL6 | sh \ ```bash test -d /nix || (sudo mkdir -pv -m 0755 /nix/var/nix && sudo -k chown -Rv "$USER": /nix); \ -test $(stat -c %a /nix) -eq 0755 || sudo -kv chmod -v 0755 /nix +test $(stat -c %a /nix) -eq 0755 || sudo -k chmod -v 0755 /nix test -f nix || curl -L https://hydra.nixos.org/build/228013056/download/1/nix > nix \ -&& chmod -v +x nix \ +&& chmod -v 0755 nix \ && ./nix \ --option experimental-features 'nix-command flakes' \ registry \ @@ -93,16 +93,16 @@ test -f nix || curl -L https://hydra.nixos.org/build/228013056/download/1/nix > --print-out-paths \ nixpkgs#busybox)"/bin/busybox \ && "$FULL_PATH_FOR_BUSYBOX" cp -v "$FULL_PATH_FOR_BUSYBOX" . \ -&& chmod -v +x busybox \ -&& busybox +&& chmod -v 0755 busybox \ +&& ./busybox -busybox mkdir -pv "$HOME"/.local/bin \ +./busybox mkdir -pv "$HOME"/.local/bin \ && export PATH="$HOME"/.local/bin:"$PATH" \ -&& busybox mv -v nix "$HOME"/.local/bin \ -&& busybox mkdir -pv "$HOME"/.config/nix \ -&& busybox echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf \ +&& ./busybox mv -v nix "$HOME"/.local/bin \ +&& ./busybox mkdir -pv "$HOME"/.config/nix \ +&& ./busybox echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf \ && nix flake --version \ -&& busybox rm -v busybox +&& ./busybox rm -v busybox ``` From 767a04a31fb14da2898998b5e17ea45cfd544d09 Mon Sep 17 00:00:00 2001 From: Pedro Date: Sun, 30 Jul 2023 16:10:06 -0300 Subject: [PATCH 179/191] Volta com poetry --- profile/README.md | 109 +++++++++++++++++++++++++- templates/start-slim-config/flake.nix | 2 +- 2 files changed, 108 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index d3b9b55..323b74f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -117,8 +117,45 @@ echo $LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD ## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador -Versão curta: +Para ajudar a testar: ```bash +cat << 'EOF' >> Dockerfile +FROM docker.io/library/fedora:39 + +# RUN dnf -y install httpd; dnf clean all; systemctl enable httpd +RUN dnf -y install hostname systemd xz + +RUN groupadd abcgroup \ + && adduser \ + --comment '"An unprivileged user with an group"' \ + --gid abcgroup \ + --uid 3322 \ + abcuser \ + && echo 'abcuser ALL=(ALL) NOPASSWD:SETENV: ALL' > /etc/sudoers.d/abcuser \ + && usermod --append --groups kvm abcuser + +EXPOSE 80 + +CMD [ "/sbin/init" ] +EOF + +podman build --tag fedora39-systemd . + +podman kill test-fedora39-systemd \ +&& podman rm --force test-fedora39-systemd || true \ +&& podman \ +run \ +--env="USER=abcuser" \ +--detach=true \ +--name=test-fedora39-systemd \ +--interactive=true \ +--tty=true \ +--privileged=true \ +--publish=8080:80 \ +--rm=true \ +fedora39-systemd \ +&& podman ps + podman \ exec \ @@ -130,8 +167,76 @@ test-fedora39-systemd \ bash \ -c \ ' -wget -qO- http://ix.io/4Blu || curl -L http://ix.io/4Blu | sh +systemctl status swap.target \ +&& systemctl status dbus.socket \ +&& systemctl status system.slice \ +&& systemctl status user.slice +' + +podman \ +exec \ +--interactive=true \ +--tty=true \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +bash \ +-c \ ' +wget -qO- http://ix.io/4Bqe || curl -L http://ix.io/4Bqe | sh \ +&& . "$HOME"/."$(basename $SHELL)"rc \ +&& nix flake --version +' + +podman \ +exec \ +--interactive=true \ +--tty=true \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +bash \ +-c \ +' +wget -qO- http://ix.io/4Bqe || curl -L http://ix.io/4Bqe | sh \ +&& . "$HOME"/."$(basename $SHELL)"rc +wget -qO- http://ix.io/4Bqg || curl -L http://ix.io/4Bqg | sh +hms +nix store gc -v && nix store optimise -v +' + +#podman \ +#exec \ +#--interactive=true \ +#--tty=true \ +#--user=abcuser \ +#--workdir=/home/abcuser \ +#test-fedora39-systemd \ +#bash \ +#-c \ +#' +#. "$HOME"/."$(basename $SHELL)"rc +#wget -qO- http://ix.io/4Bqg || curl -L http://ix.io/4Bqg | sh +#' +# +#podman \ +#exec \ +#--interactive=true \ +#--tty=true \ +#--user=abcuser \ +#--workdir=/home/abcuser \ +#test-fedora39-systemd \ +#bash + + +podman \ +exec \ +--interactive=true \ +--tty=true \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +.nix-profile/bin/zsh ``` Notas: diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index 8e3acad..b94643d 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -68,7 +68,7 @@ curl gnumake patchelf - # poetry + poetry python3Full tmate ]; From 5fdcccc4e3bc00d160850dfafb0bf2b22e1060dc Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 9 Aug 2023 19:40:07 -0300 Subject: [PATCH 180/191] Adds link --- templates/start-slim-config/flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/start-slim-config/flake.nix b/templates/start-slim-config/flake.nix index b94643d..b113a8f 100644 --- a/templates/start-slim-config/flake.nix +++ b/templates/start-slim-config/flake.nix @@ -11,6 +11,7 @@ --override-input nixpkgs github:NixOS/nixpkgs/$(nix eval --impure --raw --expr '(builtins.getFlake "github:NixOS/nixpkgs/release-23.05").rev') # https://channels.nix.gsc.io/nixos-22.11/history + # https://github.com/NixOS/nix/issues/3779#issuecomment-653598626 nix flake lock \ --override-input nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ --override-input home-manager github:nix-community/home-manager/b372d7f8d5518aaba8a4058a453957460481afbc From e002b7ea87e1fe8c22939f8ba0ff17ec0fe290e6 Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 14 Aug 2023 00:26:38 -0300 Subject: [PATCH 181/191] Updates commit hash for nixpkgs --- profile/README.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/profile/README.md b/profile/README.md index 323b74f..3d4f09f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1328,22 +1328,21 @@ ssh-keygen -R '[localhost]:10022' # Oh crap, it made me wast many many days ssh-add id_ed25519 +#--option eval-cache false \ +#--option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ +#--option extra-substituters "s3://playing-bucket-nix-cache-test" \ +# --max-jobs 0 \ nix \ ---option eval-cache false \ ---option extra-trusted-public-keys binarycache-1:XiPHS/XT/ziMHu5hGoQ8Z0K88sa1Eqi5kFTYyl33FJg= \ ---option extra-substituters "s3://playing-bucket-nix-cache-test" \ build \ ---keep-failed \ ---max-jobs 0 \ --no-link \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/5fdcccc4e3bc00d160850dfafb0bf2b22e1060dc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/c5ff24579ff2dfe933e517660ab218e8bacfe9e1#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ +github:PedroRegisPOAR/.github/5fdcccc4e3bc00d160850dfafb0bf2b22e1060dc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & @@ -1365,7 +1364,15 @@ nixuser@localhost \ Refs.: - https://stackoverflow.com/questions/20840012/ssh-remote-host-identification-has-changed#comment89964721_23150466 - +mkdir -pv "$HOME"/.local/bin \ +&& export PATH="$HOME"/.local/bin:"$PATH" \ +&& curl -L https://hydra.nixos.org/build/228013056/download/1/nix > nix \ +&& mv nix "$HOME"/.local/bin \ +&& chmod +x "$HOME"/.local/bin/nix \ +&& mkdir -pv "$HOME"/.config/nix \ +&& echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf \ +&& nix flake --version \ +&& nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b ```bash export CONTAINER_HOST=ssh://nixuser@localhost:10022/run/user/1234/podman/podman.sock From 6dabb7d4dfb72a7cde43cbd3f77f9cdf5a99726e Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 14 Aug 2023 00:42:45 -0300 Subject: [PATCH 182/191] WIP --- flake.nix | 14 +++++++------- profile/README.md | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 9f5301c..2d29494 100644 --- a/flake.nix +++ b/flake.nix @@ -139,11 +139,11 @@ virtualisation = { # following configuration is added only when building VM with build-vm - memorySize = 3072; # Use MiB memory. + memorySize = 3*1024; # Use MiB memory. # nixos-disk-image> ERROR: cptofs failed. diskSize might be too small for closure. diskSize = 15*1024; # Use MiB memory. - cores = 7; # Simulate 3 cores. + cores = 7; # Simulate/Emulates number of cores. # podman.enable = true; @@ -176,7 +176,7 @@ readOnlyStore = true; }; - boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + # boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; # Enable the X11 windowing system. services.xserver = { @@ -347,11 +347,11 @@ virtualisation = { # following configuration is added only when building VM with build-vm - memorySize = 3072; # Use MiB memory. + memorySize = 3*1024; # Use MiB memory. # nixos-disk-image> ERROR: cptofs failed. diskSize might be too small for closure. diskSize = 15*1024; # Use MiB memory. - cores = 7; # Simulate 3 cores. + cores = 7; # Simulate/Emulates number of cores. # podman.enable = true; @@ -555,7 +555,7 @@ # following configuration is added only when building VM with build-vm memorySize = 3072; # Use MiB memory. diskSize = 4096; # Use MiB memory. - cores = 7; # Simulate 3 cores. + cores = 7; # Simulate/Emulates number of cores. # docker.enable = true; @@ -735,7 +735,7 @@ virtualisation = { # following configuration is added only when building VM with build-vm - memorySize = 3072; # Use MiB memory. + memorySize = 3 * 16; # Use MiB memory. diskSize = 1024 * 16; # Use MiB memory. cores = 6; # Simulate 6 cores. diff --git a/profile/README.md b/profile/README.md index 3d4f09f..86bdbe9 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1364,6 +1364,8 @@ nixuser@localhost \ Refs.: - https://stackoverflow.com/questions/20840012/ssh-remote-host-identification-has-changed#comment89964721_23150466 + +```bash mkdir -pv "$HOME"/.local/bin \ && export PATH="$HOME"/.local/bin:"$PATH" \ && curl -L https://hydra.nixos.org/build/228013056/download/1/nix > nix \ @@ -1373,6 +1375,8 @@ mkdir -pv "$HOME"/.local/bin \ && echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf \ && nix flake --version \ && nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b +``` + ```bash export CONTAINER_HOST=ssh://nixuser@localhost:10022/run/user/1234/podman/podman.sock From cca3dec839c95c6df14453f024ca625d6e6b3f5f Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 14 Aug 2023 09:01:34 -0300 Subject: [PATCH 183/191] Adds ssh-add --- profile/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/profile/README.md b/profile/README.md index 86bdbe9..6e18501 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1300,7 +1300,7 @@ mkdir -pv ~/sandbox/sandbox && cd $_ export HOST_MAPPED_PORT=10022 export REMOVE_DISK=true export QEMU_NET_OPTS='hostfwd=tcp::'"$HOST_MAPPED_PORT"'-:'"$HOST_MAPPED_PORT"',hostfwd=tcp::8000-:8000' -export QEMU_OPTS='-nographic' +# export QEMU_OPTS='-nographic' export SHARED_DIR="$(pwd)" "$REMOVE_DISK" && rm -fv nixos.qcow2 @@ -1338,11 +1338,11 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/5fdcccc4e3bc00d160850dfafb0bf2b22e1060dc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/6dabb7d4dfb72a7cde43cbd3f77f9cdf5a99726e#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/5fdcccc4e3bc00d160850dfafb0bf2b22e1060dc#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ +github:PedroRegisPOAR/.github/6dabb7d4dfb72a7cde43cbd3f77f9cdf5a99726e#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & @@ -1378,6 +1378,10 @@ mkdir -pv "$HOME"/.local/bin \ ``` ```bash +ssh-keygen -R '[localhost]:10022' +# Oh crap, it made me wast many many days +ssh-add id_ed25519 + export CONTAINER_HOST=ssh://nixuser@localhost:10022/run/user/1234/podman/podman.sock podman run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' From 2e545b9b040150742c5dca89e98b0540e4021ba9 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 15 Aug 2023 01:17:56 -0300 Subject: [PATCH 184/191] Adds more disk space --- flake.nix | 4 ++-- profile/README.md | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index 2d29494..4d65db5 100644 --- a/flake.nix +++ b/flake.nix @@ -94,7 +94,7 @@ ]; packages = with pkgs; [ direnv - gitFull + git xorg.xclock file btop @@ -142,7 +142,7 @@ memorySize = 3*1024; # Use MiB memory. # nixos-disk-image> ERROR: cptofs failed. diskSize might be too small for closure. - diskSize = 15*1024; # Use MiB memory. + diskSize = 19*1024; # Use MiB memory. cores = 7; # Simulate/Emulates number of cores. # podman.enable = true; diff --git a/profile/README.md b/profile/README.md index 6e18501..77057ab 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1365,6 +1365,20 @@ Refs.: - https://stackoverflow.com/questions/20840012/ssh-remote-host-identification-has-changed#comment89964721_23150466 +```bash +ssh-keygen -R '[localhost]:10022' +# Oh crap, it made me wast many many days +ssh-add id_ed25519 + +export CONTAINER_HOST=ssh://nixuser@localhost:10022/run/user/1234/podman/podman.sock + +podman run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' +``` +Refs.: +- + + + ```bash mkdir -pv "$HOME"/.local/bin \ && export PATH="$HOME"/.local/bin:"$PATH" \ @@ -1377,17 +1391,7 @@ mkdir -pv "$HOME"/.local/bin \ && nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b ``` -```bash -ssh-keygen -R '[localhost]:10022' -# Oh crap, it made me wast many many days -ssh-add id_ed25519 - -export CONTAINER_HOST=ssh://nixuser@localhost:10022/run/user/1234/podman/podman.sock -podman run -it --rm docker.io/library/alpine sh -c 'cat /etc/os-*release' -``` -Refs.: -- ```bash From 9d8a6f49e8402f4bc3eb80ad03f26046cbd74b8f Mon Sep 17 00:00:00 2001 From: Pedro Date: Mon, 16 Oct 2023 16:51:45 -0300 Subject: [PATCH 185/191] Multiplos refactors --- profile/README.md | 414 +++++++++++++++++++++++++++++----------------- 1 file changed, 262 insertions(+), 152 deletions(-) diff --git a/profile/README.md b/profile/README.md index 77057ab..d2958d4 100644 --- a/profile/README.md +++ b/profile/README.md @@ -14,7 +14,7 @@ git clone git@github.com:PedroRegisPOAR/.github.git \ Versão curta: para linux ```bash -wget -qO- http://ix.io/4Bqe || curl -L http://ix.io/4Bqe | sh \ +wget -qO- http://ix.io/4Bqe sh || curl -L http://ix.io/4Bqe | sh \ && . "$HOME"/."$(basename $SHELL)"rc \ && nix flake --version ``` @@ -65,183 +65,115 @@ Basta atualizar o hash/id da instalação.
-### Quebrado! Experimental, nix estaticamente compilado, usando /nix +### Experimental, nix estaticamente compilado, usando /nix + + +Versão curta: ```bash -wget -qO- http://ix.io/4AL6 | sh \ -&& . "$HOME"/."$(basename $SHELL)"rc \ +wget -qO- http://ix.io/4Jaq | sh \ +&& . "$HOME"/.profile \ && nix flake --version ``` +
+ Versão longa (click para expandir): ```bash test -d /nix || (sudo mkdir -pv -m 0755 /nix/var/nix && sudo -k chown -Rv "$USER": /nix); \ test $(stat -c %a /nix) -eq 0755 || sudo -k chmod -v 0755 /nix -test -f nix || curl -L https://hydra.nixos.org/build/228013056/download/1/nix > nix \ -&& chmod -v 0755 nix \ -&& ./nix \ - --option experimental-features 'nix-command flakes' \ - registry \ - pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ -&& FULL_PATH_FOR_BUSYBOX="$(./nix \ - --option experimental-features 'nix-command flakes' \ - build \ - --no-link \ - --print-build-logs \ - --print-out-paths \ - nixpkgs#busybox)"/bin/busybox \ -&& "$FULL_PATH_FOR_BUSYBOX" cp -v "$FULL_PATH_FOR_BUSYBOX" . \ -&& chmod -v 0755 busybox \ -&& ./busybox - -./busybox mkdir -pv "$HOME"/.local/bin \ -&& export PATH="$HOME"/.local/bin:"$PATH" \ -&& ./busybox mv -v nix "$HOME"/.local/bin \ -&& ./busybox mkdir -pv "$HOME"/.config/nix \ -&& ./busybox echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf \ -&& nix flake --version \ -&& ./busybox rm -v busybox -``` +test -f nix || curl -L https://hydra.nixos.org/build/237228729/download/2/nix > nix && chmod -v +x nix +test -f nix || wget https://hydra.nixos.org/build/237228729/download/2/nix && chmod -v +x nix +./nix \ +--option experimental-features 'nix-command flakes' \ +registry \ +pin \ +nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b -```bash -# https://github.com/NixOS/nix/issues/6976 -URL=https://hydra.nixos.org/job/nix/master/buildStatic.x86_64-linux/latest -LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD="$(curl $URL | grep '"https://hydra.nixos.org/build/' | cut -d'/' -f5 | cut -d'"' -f1)" +./nix \ +--option experimental-features 'nix-command flakes' \ +shell \ +--ignore-environment \ +--keep HOME \ +--keep USER \ +nixpkgs#busybox-sandbox-shell \ +nixpkgs#toybox \ +-c \ +sh<<'COMMANDS' +toybox echo $HOME +toybox echo $USER + +type cd \ +&& type echo \ +&& type export \ +&& type type + +toybox mkdir -pv "$HOME"/.local/bin \ +&& toybox mv -v nix "$HOME"/.local/bin \ +&& cd "$HOME"/.local/bin \ +&& toybox ln -sfv nix nix-build \ +&& toybox ln -sfv nix nix-channel \ +&& toybox ln -sfv nix nix-collect-garbage \ +&& toybox ln -sfv nix nix-copy-closure \ +&& toybox ln -sfv nix nix-daemon \ +&& toybox ln -sfv nix nix-env \ +&& toybox ln -sfv nix nix-hash \ +&& toybox ln -sfv nix nix-instantiate \ +&& toybox ln -sfv nix nix-prefetch-url \ +&& toybox ln -sfv nix nix-shell \ +&& toybox ln -sfv nix nix-store \ +&& cd \ +&& toybox mkdir -pv "$HOME"/.config/nix \ +&& toybox grep 'experimental-features' "$HOME"/.config/nix/nix.conf -q || (toybox echo 'experimental-features = nix-command flakes' >> "$HOME"/.config/nix/nix.conf) \ +&& toybox grep '.local' "$HOME"/.profile -q || (echo 'export PATH="$HOME"/.nix-profile/bin:"$HOME"/.local/bin:"$PATH"' >> "$HOME"/.profile) +COMMANDS -echo $LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD +. "$HOME"/.profile \ +&& nix flake --version \ +&& nix flake metadata nixpkgs ``` -## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador - - -Para ajudar a testar: +Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. ```bash -cat << 'EOF' >> Dockerfile -FROM docker.io/library/fedora:39 - -# RUN dnf -y install httpd; dnf clean all; systemctl enable httpd -RUN dnf -y install hostname systemd xz - -RUN groupadd abcgroup \ - && adduser \ - --comment '"An unprivileged user with an group"' \ - --gid abcgroup \ - --uid 3322 \ - abcuser \ - && echo 'abcuser ALL=(ALL) NOPASSWD:SETENV: ALL' > /etc/sudoers.d/abcuser \ - && usermod --append --groups kvm abcuser +nano arquivo.txt +``` -EXPOSE 80 +Após salvar e fechar o arquivo: +```bash +cat arquivo.txt | curl -F 'f:1=<-' ix.io +``` -CMD [ "/sbin/init" ] -EOF +Basta atualizar o hash/id da instalação. -podman build --tag fedora39-systemd . +
-podman kill test-fedora39-systemd \ -&& podman rm --force test-fedora39-systemd || true \ -&& podman \ -run \ ---env="USER=abcuser" \ ---detach=true \ ---name=test-fedora39-systemd \ ---interactive=true \ ---tty=true \ ---privileged=true \ ---publish=8080:80 \ ---rm=true \ -fedora39-systemd \ -&& podman ps +
+ Como obter id do latest build que obteve sucesso no hydra? (click para expandir): -podman \ -exec \ ---interactive=true \ ---tty=true \ ---user=abcuser \ ---workdir=/home/abcuser \ -test-fedora39-systemd \ -bash \ --c \ -' -systemctl status swap.target \ -&& systemctl status dbus.socket \ -&& systemctl status system.slice \ -&& systemctl status user.slice -' +```bash +# https://github.com/NixOS/nix/issues/6976 +URL=https://hydra.nixos.org/job/nix/master/buildStatic.x86_64-linux/latest +LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD="$(curl $URL | grep '"https://hydra.nixos.org/build/' | cut -d'/' -f5 | cut -d'"' -f1)" -podman \ -exec \ ---interactive=true \ ---tty=true \ ---user=abcuser \ ---workdir=/home/abcuser \ -test-fedora39-systemd \ -bash \ --c \ -' -wget -qO- http://ix.io/4Bqe || curl -L http://ix.io/4Bqe | sh \ -&& . "$HOME"/."$(basename $SHELL)"rc \ -&& nix flake --version -' +echo $LATEST_ID_OF_NIX_STATIC_HYDRA_SUCCESSFUL_BUILD +``` -podman \ -exec \ ---interactive=true \ ---tty=true \ ---user=abcuser \ ---workdir=/home/abcuser \ -test-fedora39-systemd \ -bash \ --c \ -' -wget -qO- http://ix.io/4Bqe || curl -L http://ix.io/4Bqe | sh \ -&& . "$HOME"/."$(basename $SHELL)"rc -wget -qO- http://ix.io/4Bqg || curl -L http://ix.io/4Bqg | sh -hms -nix store gc -v && nix store optimise -v -' +
-#podman \ -#exec \ -#--interactive=true \ -#--tty=true \ -#--user=abcuser \ -#--workdir=/home/abcuser \ -#test-fedora39-systemd \ -#bash \ -#-c \ -#' -#. "$HOME"/."$(basename $SHELL)"rc -#wget -qO- http://ix.io/4Bqg || curl -L http://ix.io/4Bqg | sh -#' -# -#podman \ -#exec \ -#--interactive=true \ -#--tty=true \ -#--user=abcuser \ -#--workdir=/home/abcuser \ -#test-fedora39-systemd \ -#bash +## Instalação do nix para MULTIPLOS usuários compartilhando o mesmo computador -podman \ -exec \ ---interactive=true \ ---tty=true \ ---user=abcuser \ ---workdir=/home/abcuser \ -test-fedora39-systemd \ -.nix-profile/bin/zsh +Versão curta: +```bash +CURL_OR_WGET_OR_ERROR=$((curl -V &> /dev/null && echo curl -L) || (wget -V &> /dev/null && echo wget -qO-) || echo Neither curl nor wget are installed) \ +&& $CURL_OR_WGET_OR_ERROR http://ix.io/4J25 | sh \ +&& sudo "$SHELL" -lc 'nix --version' ``` -Notas: -- [Allow gc-ing with a rootless daemon](https://github.com/NixOS/nix/pull/5380) -- [Extra-secure store objects that Nix cannot modify](https://github.com/NixOS/nix/issues/7471)
Versão longa (click para expandir): @@ -263,9 +195,11 @@ NAME_SHELL=$(basename $SHELL) \ && echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ && echo '. "$HOME"/.nix-profile/etc/profile.d/nix.sh' >> "$HOME"/."$NAME_SHELL"rc \ && echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'export DIRENV_LOG_FORMAT=""' >> "$HOME"/."$NAME_SHELL"rc \ && echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/.profile \ && echo '. "$HOME"/.nix-profile/etc/profile.d/nix.sh' >> "$HOME"/.profile \ && echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile \ +&& echo 'export DIRENV_LOG_FORMAT=""' >> "$HOME"/.profile \ && . "$HOME"/."$NAME_SHELL"rc \ && . "$HOME"/.profile \ && nix flake --version \ @@ -281,10 +215,13 @@ sudo ln -sfv "$HOME"/.nix-profile /nix/var/nix/profiles/default/ \ && NAME_SHELL=$(basename $SHELL) \ && echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/."$NAME_SHELL"rc \ && echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/."$NAME_SHELL"rc \ +&& echo 'export DIRENV_LOG_FORMAT=""' >> "$HOME"/."$NAME_SHELL"rc \ && echo 'export NIX_CONFIG="extra-experimental-features = nix-command flakes"' >> "$HOME"/.profile \ -&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile +&& echo 'eval "$(direnv hook '"$NAME_SHELL"')"' >> "$HOME"/.profile \ +&& echo 'export DIRENV_LOG_FORMAT=""' >> "$HOME"/.profile ``` + Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. ```bash nano arquivo.txt @@ -299,6 +236,79 @@ Basta atualizar o hash/id da instalação.
+ +#### Removendo nix mult-user + +Primeiro para o `root`: +```bash +sudo systemctl stop nix-daemon.service +sudo systemctl disable nix-daemon.socket nix-daemon.service +sudo systemctl daemon-reload + + +# test -f /etc/bash.bashrc.backup-before-nix && sudo mv -v /etc/bash.bashrc.backup-before-nix /etc/bash.bashrc +sudo \ +rm \ +-rfv \ +"$HOME"/.nix-profile-*-link \ +/etc/zshrc \ +/etc/bashrc \ +/etc/bash.bashrc.backup-before-nix \ +/etc/nix \ +/etc/profile.d/nix.sh \ +/etc/tmpfiles.d/nix-daemon.conf \ +/nix \ +/root/.nix-channels \ +/root/.nix-defexpr \ +/root/.nix-profile + + +test -f /etc/bash.bashrc && (grep -q nix /etc/bash.bashrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/bash.bashrc) +test -f /etc/bashrc && (grep -q nix /etc/bashrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/bashrc) +test -f /etc/profile && (grep -q nix /etc/profile && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/profile) +test -f /etc/zsh/zshrc && (grep -q nix /etc/zsh/zshrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/zsh/zshrc) +test -f /etc/zshrc && (grep -q nix /etc/zshrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/zshrc) + + +sudo sed -i '/nix-profile/d' ~/.$(basename $SHELL)rc \ +&& sudo sed -i '/extra-experimental-features/d' ~/.$(basename $SHELL)rc \ +&& sudo sed -i '/direnv/d' ~/.$(basename $SHELL)rc \ +&& sudo sed -i '/DIRENV_LOG_FORMAT=/d' ~/.$(basename $SHELL)rc + +sudo sed -i '/nix-profile/d' ~/.profile \ +&& sudo sed -i '/extra-experimental-features/d' ~/.profile \ +&& sudo sed -i '/direnv/d' ~/.profile \ +&& sudo sed -i '/DIRENV_LOG_FORMAT=/d' ~/.profile + +for i in $(seq 1 32); do + sudo userdel nixbld$i +done +sudo groupdel nixbld + +sudo rm -frv /tmp/* +``` + +Para cada usuário que tenha previamente instalado `nix`: +```bash +sed -i '/nix-profile/d' ~/.$(basename $SHELL)rc \ +&& sed -i '/extra-experimental-features/d' ~/.$(basename $SHELL)rc \ +&& sed -i '/direnv/d' ~/.$(basename $SHELL)rc \ +&& sed -i '/DIRENV_LOG_FORMAT=/d' ~/.$(basename $SHELL)rc + +sed -i '/nix-profile/d' ~/.profile \ +&& sed -i '/extra-experimental-features/d' ~/.profile \ +&& sed -i '/direnv/d' ~/.profile \ +&& sed -i '/DIRENV_LOG_FORMAT=/d' ~/.profile + +rm -rfv "$HOME"/{.nix-channels,.nix-defexpr,.nix-profile,.config/nixpkgs,.cache/nix} +rm -fv "$HOME"/.nix-profile-*-link +``` +Refs.: +- https://www.extrema.is/blog/2022/01/05/uninstalling-multi-user-nix +- https://nixos.org/manual/nix/stable/installation/uninstall#linux +- https://github.com/NixOS/nix/issues/1402 + + ### Para MULTIPLOS usuários compartilhando o mesmo computador O script abaixo cria um usuário com: @@ -318,7 +328,7 @@ sudo passwd "$NOME_DO_SEU_USER" ``` -Para cada usuário criado é necessário adicionar esse "hack" para poder utilizar o `podman`: +Para cada usuário criado que é necessário adicionar esse "hack" para poder utilizar o `podman`: ```bash NAME_SHELL=$(basename $SHELL) @@ -364,6 +374,106 @@ podman info 1> /dev/null 2> /dev/null \ Feche o terminal. +
+ Imagem OCI com systemd (para ajudar a testar): + +```bash +cat << 'EOF' >> Dockerfile +FROM docker.io/library/fedora:39 + + +RUN dnf -y install hostname systemd xz + +RUN groupadd abcgroup \ + && adduser \ + --comment '"An unprivileged user with an group"' \ + --gid abcgroup \ + --uid 3322 \ + abcuser \ + && echo 'abcuser ALL=(ALL) NOPASSWD:SETENV: ALL' > /etc/sudoers.d/abcuser \ + && usermod --append --groups kvm abcuser + +CMD [ "/sbin/init" ] +EOF + +podman build --tag fedora39-systemd . + +podman kill test-fedora39-systemd \ +&& podman rm --force test-fedora39-systemd || true \ +&& podman \ +run \ +--env="USER=abcuser" \ +--detach=true \ +--name=test-fedora39-systemd \ +--interactive=true \ +--tty=true \ +--privileged=true \ +--rm=true \ +fedora39-systemd \ +&& podman ps + +# Para checar qus o systemd está funcionando +podman \ +exec \ +--interactive=true \ +--tty=true \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +bash \ +-c \ +' +systemctl status swap.target \ +&& systemctl status dbus.socket \ +&& systemctl status system.slice \ +&& systemctl status user.slice +' + +podman \ +exec \ +--interactive=true \ +--tty=false \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +bash<<'COMMANDS' +CURL_OR_WGET_OR_ERROR=$((curl -V &> /dev/null && echo curl -L) || (wget -V &> /dev/null && echo wget -qO-) || echo Neither curl nor wget are installed) \ +&& $CURL_OR_WGET_OR_ERROR http://ix.io/4J25 | sh \ +&& sudo "$SHELL" -lc 'nix --version' +COMMANDS + + +podman \ +exec \ +--interactive=true \ +--tty=true \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +bash \ +-cl \ +' +nix flake --version +' + + +podman \ +exec \ +--interactive=true \ +--tty=true \ +--user=abcuser \ +--workdir=/home/abcuser \ +test-fedora39-systemd \ +bash +``` + +Notas: +- [Allow gc-ing with a rootless daemon](https://github.com/NixOS/nix/pull/5380) +- [Extra-secure store objects that Nix cannot modify](https://github.com/NixOS/nix/issues/7471) + +
+ + ### Mac @@ -1338,11 +1448,11 @@ build \ --no-show-trace \ --print-build-logs \ --print-out-paths \ -github:PedroRegisPOAR/.github/6dabb7d4dfb72a7cde43cbd3f77f9cdf5a99726e#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm +github:PedroRegisPOAR/.github/2e545b9b040150742c5dca89e98b0540e4021ba9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm nix \ run \ -github:PedroRegisPOAR/.github/6dabb7d4dfb72a7cde43cbd3f77f9cdf5a99726e#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ +github:PedroRegisPOAR/.github/2e545b9b040150742c5dca89e98b0540e4021ba9#nixosConfigurations.x86_64-linux.nixosBuildVMX86_64LinuxPodman.config.system.build.vm \ < /dev/null & From a865216a4353339fbc4aa8f790073d0ae928c628 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 24 Oct 2023 16:35:46 -0300 Subject: [PATCH 186/191] =?UTF-8?q?Salva=20instru=C3=A7=C3=B5es=20sobre=20?= =?UTF-8?q?como=20desinstalar=20o=20nix=20daemon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/profile/README.md b/profile/README.md index d2958d4..c3b74ae 100644 --- a/profile/README.md +++ b/profile/README.md @@ -309,6 +309,16 @@ Refs.: - https://github.com/NixOS/nix/issues/1402 +> Note: se o nix foi instalado via algum gerenciador de pacotes, +> por exemplo, apt-get, será necessário fazer algo como: + +```bash +# Note que esses comandos não removem o diretório /nix +sudo apt-get purge -y nix-bin \ +&& sudo apt-get autoremove -y nix-bin +``` + + ### Para MULTIPLOS usuários compartilhando o mesmo computador O script abaixo cria um usuário com: From fd9ed0a5550953ac5a1879b3cb19e6994602cc3e Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 24 Oct 2023 18:44:00 -0300 Subject: [PATCH 187/191] =?UTF-8?q?Algumas=20corre=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/profile/README.md b/profile/README.md index c3b74ae..e225ddf 100644 --- a/profile/README.md +++ b/profile/README.md @@ -408,21 +408,20 @@ EOF podman build --tag fedora39-systemd . -podman kill test-fedora39-systemd \ +podman kill test-fedora39-systemd || true \ && podman rm --force test-fedora39-systemd || true \ && podman \ run \ ---env="USER=abcuser" \ --detach=true \ --name=test-fedora39-systemd \ ---interactive=true \ +--interactive=false \ --tty=true \ --privileged=true \ --rm=true \ -fedora39-systemd \ +localhost/fedora39-systemd \ && podman ps -# Para checar qus o systemd está funcionando +# Para checar que o systemd está funcionando podman \ exec \ --interactive=true \ From 1cb354f4512f5b48e4611d96286668b949d20ba4 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 31 Oct 2023 13:16:19 -0300 Subject: [PATCH 188/191] Corrige pin e adiciona detalhes --- profile/README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/profile/README.md b/profile/README.md index e225ddf..5801c51 100644 --- a/profile/README.md +++ b/profile/README.md @@ -496,9 +496,41 @@ curl -L http://ix.io/4vEW | sh Após abrir o terminal: ```bash -nix registry pin github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b +nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ +&& nix flake metadata nixpkgs +``` + + +
+ Detalhes: nix registry {add,pin,remove} (click para expandir): + +```bash +nix registry add nixpkgs github:NixOS/nixpkgs/nixos-22.11 ``` +Refs.: +- https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-registry-add#examples +```bash +nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b +``` +Refs.: +- https://discourse.nixos.org/t/how-to-pin-nix-registry-nixpkgs-to-release-channel/14883 + +```bash +nix registry remove nixpkgs +``` +Refs.: +- https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-registry-remove#examples + + +```bash +nix registry list +``` + +```bash +nix flake metadata nixpkgs +``` +
Testando a instalação: ```bash @@ -514,6 +546,18 @@ NIX_RELEASE_VERSION=2.10.2 \ && echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile ``` +```bash +echo 'system-features = benchmark big-parallel kvm nixos-test' | tee /var/root/.config/nix/nix.conf \ +&& echo 'experimental-features = nix-command flakes' | tee /var/root/.config/nix/nix.conf \ +&& echo 'show-trace = true' | tee /var/root/.config/nix/nix.conf +``` + +```bash +echo 'system-features = benchmark big-parallel kvm nixos-test' | sudo tee /var/root/.config/nix/nix.conf \ +&& echo 'experimental-features = nix-command flakes' | sudo tee /var/root/.config/nix/nix.conf \ +&& echo 'show-trace = true' | sudo tee /var/root/.config/nix/nix.conf +``` + Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. ```bash nano arquivo.txt From 4264a19c0cfa8332f31b9822ccfcb3480bed2c0f Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 1 Nov 2023 11:52:11 -0300 Subject: [PATCH 189/191] =?UTF-8?q?Remove=20instru=C3=A7=C3=B5es=20para=20?= =?UTF-8?q?Mac?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 153 ---------------------------------------------- 1 file changed, 153 deletions(-) diff --git a/profile/README.md b/profile/README.md index 5801c51..d596d7f 100644 --- a/profile/README.md +++ b/profile/README.md @@ -484,159 +484,6 @@ Notas: -### Mac - - -Versão curta: -```bash -curl -L http://ix.io/4vEW | sh -``` - -É obrigatório que o terminal seja fechado. - -Após abrir o terminal: -```bash -nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b \ -&& nix flake metadata nixpkgs -``` - - -
- Detalhes: nix registry {add,pin,remove} (click para expandir): - -```bash -nix registry add nixpkgs github:NixOS/nixpkgs/nixos-22.11 -``` -Refs.: -- https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-registry-add#examples - -```bash -nix registry pin nixpkgs github:NixOS/nixpkgs/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b -``` -Refs.: -- https://discourse.nixos.org/t/how-to-pin-nix-registry-nixpkgs-to-release-channel/14883 - -```bash -nix registry remove nixpkgs -``` -Refs.: -- https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-registry-remove#examples - - -```bash -nix registry list -``` - -```bash -nix flake metadata nixpkgs -``` -
- -Testando a instalação: -```bash -nix profile install nixpkgs#{curl,direnv,git,jq,wget} -``` - -
- Versão longa Mac (click para expandir): - -```bash -NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s \ -&& echo 'export NIX_CONFIG="extra-experimental-features = 'nix-command flakes'"' >> "$HOME"/.zprofile -``` - -```bash -echo 'system-features = benchmark big-parallel kvm nixos-test' | tee /var/root/.config/nix/nix.conf \ -&& echo 'experimental-features = nix-command flakes' | tee /var/root/.config/nix/nix.conf \ -&& echo 'show-trace = true' | tee /var/root/.config/nix/nix.conf -``` - -```bash -echo 'system-features = benchmark big-parallel kvm nixos-test' | sudo tee /var/root/.config/nix/nix.conf \ -&& echo 'experimental-features = nix-command flakes' | sudo tee /var/root/.config/nix/nix.conf \ -&& echo 'show-trace = true' | sudo tee /var/root/.config/nix/nix.conf -``` - -Para criar a versão curta, crie um arquivo e copie e cole o bloco de código acima no arquivo. -```bash -nano arquivo.txt -``` - -Após salvar e fechar o arquivo: -```bash -cat arquivo.txt | curl -F 'f:1=<-' ix.io -``` - -Basta atualizar o hash/id da instalação. - -
- - -#### Desinstalando nix no Mac - -> Infelizmente não é algo "automágico". - - -1) Script aglutinado -```bash -jq --version 1> /dev/null 2> /dev/null || nix profile install nixpkgs#jq - -VOLUME_NIX_DEVICE_IDENTIFIER=$(diskutil info -plist /nix | plutil -convert json -o - - | jq -r '."DeviceIdentifier"') - -echo $VOLUME_NIX_DEVICE_IDENTIFIER - -sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/zshrc \ -&& sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/bashrc \ -&& sudo sed -i '' '/# Nix/,/# End Nix/d' /etc/bash.bashrc - -sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist \ -&& sudo rm -v /Library/LaunchDaemons/org.nixos.nix-daemon.plist \ -&& sudo launchctl unload /Library/LaunchDaemons/org.nixos.darwin-store.plist \ -&& sudo rm -v /Library/LaunchDaemons/org.nixos.darwin-store.plist - -sudo dscl . -delete /Groups/nixbld - -sudo sed -i '' '/nix/d' /etc/synthetic.conf \ -&& sudo rm -frv \ - /etc/bash.bashrc.backup-before-nix \ - /etc/bashrc.backup-before-nix \ - /etc/nix \ - /etc/zshrc.backup-before-nix \ - /var/root/.nix-channels \ - /var/root/.nix-defexpr \ - /var/root/.nix-profile \ - ~/.nix-channels \ - ~/.nix-defexpr \ - ~/.nix-profile \ -&& diskutil info -plist $VOLUME_NIX_DEVICE_IDENTIFIER 1>/dev/null 2>/dev/null \ -&& sudo diskutil apfs deleteVolume $VOLUME_NIX_DEVICE_IDENTIFIER -``` -Refs.: -- https://nixos.org/manual/nix/stable/installation/uninstall.html#macos -- https://github.com/NixOS/nix/issues/458 -- https://github.com/NixOS/nix/issues/6787 -- https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551552972 voltado para flakes -- https://unix.stackexchange.com/questions/507217/specific-fields-from-macos-command-diskutil-apfs-list#comment1021730_507244 -- https://apple.stackexchange.com/a/319977 -- https://fortechmenot.wordpress.com/2015/01/15/disabling-logins-for-mac-os-x-users/ -- https://apple.stackexchange.com/questions/396301/finding-volume-label-and-understanding-the-apfs-partition - - -2) -```bash -sudo reboot -``` - - -Após o reboot checar que o volume não existe: -```bash -sudo diskutil apfs list | grep 'Nix Store' -B2 -A4 - -ls -al /nix -``` - - ## Parte 2, home-manager + nix, apenas GNU/Linux From a3d333d38a0c21050bff8047d2b99c841b0c976d Mon Sep 17 00:00:00 2001 From: "Pedro O. A. Regis" Date: Mon, 11 Dec 2023 15:09:22 -0300 Subject: [PATCH 190/191] TODO: WPS --- profile/README.md | 2 +- templates/start-config-graphical-full/home.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/profile/README.md b/profile/README.md index d596d7f..a7fdd83 100644 --- a/profile/README.md +++ b/profile/README.md @@ -186,7 +186,7 @@ DAEMON_OR_NO_DAEMON='--daemon' NIX_RELEASE_VERSION=2.10.2 \ -&& curl -L https://releases.nixos.org/nix/nix-"${NIX_RELEASE_VERSION}"/install | sh -s -- "$DAEMON_OR_NO_DAEMON" +&& curl -L https://releases.nixos.org/nix/nix-2.18.1/install | sh -s -- --daemon sudo \ $SHELL \ diff --git a/templates/start-config-graphical-full/home.nix b/templates/start-config-graphical-full/home.nix index 9da4d6c..7bc6211 100644 --- a/templates/start-config-graphical-full/home.nix +++ b/templates/start-config-graphical-full/home.nix @@ -20,7 +20,7 @@ jetbrains.pycharm-community keepassxc kolourpaint - libreoffice + # libreoffice # WPS? https://github.com/imobanco/.github/pull/1#discussion_r1175734524 obsidian okular peek From 7747d60d7c56ee9c67b63b20f8cad787322ff6cd Mon Sep 17 00:00:00 2001 From: Pedro Date: Thu, 11 Jan 2024 21:35:30 -0300 Subject: [PATCH 191/191] =?UTF-8?q?Move=20para=20outro=20repo=20para=20n?= =?UTF-8?q?=C3=A3o=20duplicar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profile/README.md | 81 ----------------------------------------------- 1 file changed, 81 deletions(-) diff --git a/profile/README.md b/profile/README.md index a7fdd83..b737fdc 100644 --- a/profile/README.md +++ b/profile/README.md @@ -237,87 +237,6 @@ Basta atualizar o hash/id da instalação.
-#### Removendo nix mult-user - -Primeiro para o `root`: -```bash -sudo systemctl stop nix-daemon.service -sudo systemctl disable nix-daemon.socket nix-daemon.service -sudo systemctl daemon-reload - - -# test -f /etc/bash.bashrc.backup-before-nix && sudo mv -v /etc/bash.bashrc.backup-before-nix /etc/bash.bashrc -sudo \ -rm \ --rfv \ -"$HOME"/.nix-profile-*-link \ -/etc/zshrc \ -/etc/bashrc \ -/etc/bash.bashrc.backup-before-nix \ -/etc/nix \ -/etc/profile.d/nix.sh \ -/etc/tmpfiles.d/nix-daemon.conf \ -/nix \ -/root/.nix-channels \ -/root/.nix-defexpr \ -/root/.nix-profile - - -test -f /etc/bash.bashrc && (grep -q nix /etc/bash.bashrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/bash.bashrc) -test -f /etc/bashrc && (grep -q nix /etc/bashrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/bashrc) -test -f /etc/profile && (grep -q nix /etc/profile && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/profile) -test -f /etc/zsh/zshrc && (grep -q nix /etc/zsh/zshrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/zsh/zshrc) -test -f /etc/zshrc && (grep -q nix /etc/zshrc && sudo sed -i '/^# Nix/,/# End Nix/d' /etc/zshrc) - - -sudo sed -i '/nix-profile/d' ~/.$(basename $SHELL)rc \ -&& sudo sed -i '/extra-experimental-features/d' ~/.$(basename $SHELL)rc \ -&& sudo sed -i '/direnv/d' ~/.$(basename $SHELL)rc \ -&& sudo sed -i '/DIRENV_LOG_FORMAT=/d' ~/.$(basename $SHELL)rc - -sudo sed -i '/nix-profile/d' ~/.profile \ -&& sudo sed -i '/extra-experimental-features/d' ~/.profile \ -&& sudo sed -i '/direnv/d' ~/.profile \ -&& sudo sed -i '/DIRENV_LOG_FORMAT=/d' ~/.profile - -for i in $(seq 1 32); do - sudo userdel nixbld$i -done -sudo groupdel nixbld - -sudo rm -frv /tmp/* -``` - -Para cada usuário que tenha previamente instalado `nix`: -```bash -sed -i '/nix-profile/d' ~/.$(basename $SHELL)rc \ -&& sed -i '/extra-experimental-features/d' ~/.$(basename $SHELL)rc \ -&& sed -i '/direnv/d' ~/.$(basename $SHELL)rc \ -&& sed -i '/DIRENV_LOG_FORMAT=/d' ~/.$(basename $SHELL)rc - -sed -i '/nix-profile/d' ~/.profile \ -&& sed -i '/extra-experimental-features/d' ~/.profile \ -&& sed -i '/direnv/d' ~/.profile \ -&& sed -i '/DIRENV_LOG_FORMAT=/d' ~/.profile - -rm -rfv "$HOME"/{.nix-channels,.nix-defexpr,.nix-profile,.config/nixpkgs,.cache/nix} -rm -fv "$HOME"/.nix-profile-*-link -``` -Refs.: -- https://www.extrema.is/blog/2022/01/05/uninstalling-multi-user-nix -- https://nixos.org/manual/nix/stable/installation/uninstall#linux -- https://github.com/NixOS/nix/issues/1402 - - -> Note: se o nix foi instalado via algum gerenciador de pacotes, -> por exemplo, apt-get, será necessário fazer algo como: - -```bash -# Note que esses comandos não removem o diretório /nix -sudo apt-get purge -y nix-bin \ -&& sudo apt-get autoremove -y nix-bin -``` - ### Para MULTIPLOS usuários compartilhando o mesmo computador