Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble with initial setup. #875

Open
BlueFalconHD opened this issue Feb 19, 2024 · 5 comments
Open

Having trouble with initial setup. #875

BlueFalconHD opened this issue Feb 19, 2024 · 5 comments

Comments

@BlueFalconHD
Copy link

I installed nix (using ). Then, I followed the steps to use nix-darwin:

mkdir -p ~/.config/nix-darwin                                                                                     
cd ~/.config/nix-darwin
nix flake init -t nix-darwin
sed -i '' "s/simple/$(scutil --get LocalHostName)/" flake.nix

Then I ran nix run nix-darwin --experimental-features "flakes nix-command" -- switch --flake ~/nix-darwin-config/, as instructed.

Then, it says I should be able to use the command nix-darwin, but it doesn't work. I am using fish shell, my config is listed below:

#!!!SUPER IMPORTANT!!!#
fish_add_path /bin/
fish_add_path /usr/bin/
fish_add_path /usr/sbin/


set -Ux SHELL /usr/bin/env fish
fish_add_path /opt/homebrew/bin/
fish_add_path /opt/homebrew/sbin/

set fish_function_path $fish_function_path ~/.config/fish/plugin-foreign-env/functions



function paths
    eval "$(/opt/homebrew/bin/brew shellenv)"
    fish_add_path /Users/hayesdombroski/.spicetify
    fish_add_path /Users/hayesdombroski/.local/bin
    fish_add_path /Users/hayesdombroski/go/bin
    fish_add_path /Users/hayesdombroski/.cargo/bin

    # add gnu coreutils
    fish_add_path /opt/homebrew/opt/coreutils/libexec/gnubin/
end

function aliases
    alias a="exa -l --sort modified -mg --git-ignore --icons"
    alias ls="exa -l --sort modified -mg --git-ignore --icons"

    # cd relative up
    # alias .1="savecd ../"
    # alias .2="savecd ../../"
    # alias .3="savecd ../../../"
    # alias .4="savecd ../../../../"
    # alias .5="savecd ../../../../../"
    # alias b="restorecd"

    # better command replacements
    alias rm="rip"
    alias cp="xcp"

end

function funcs
    function ship
        set choice "$(gum choose "  Fix" "  Feat" "  Docs" "  Style" "  Refactor" "ﭧ  Test" "  Chore" "  Revert")"
        set choice "$(string replace -r ".  " "" "$choice")" # remove the emoji and padding
        set choice "$(string lower "$choice")" # make it lowercase

        set title "$(gum input --placeholder "Title...")"
        set scope "$(gum input --placeholder "Scope...")"
        set desc "$(gum write --header "Description" --placeholder "Description..." --show-line-numbers )"

        set finaltitle "$choice\($scope\): $title"

        git add "$PWD" # add all files
        git status
        git commit -m "$finaltitle" -m "$desc"
    end

    function d
        mkdir $argv[1]
        cd $argv[1]
    end

    function f
        touch $argv[1]
        lvim $argv[1]
    end

    function savecd
        set -Ux SAVECD_LAST_DIR "$PWD"
        cd $argv[1]
    end

    function restorecd
        if test -z "$SAVECD_LAST_DIR"
            echo "\SAVECD_LAST_DIR envar is unset"
        else
            cd "$SAVECD_LAST_DIR"
        end
    end

    function weztheme
        switch $argv[1]
            case mocha
                set -Ux WEZTERM_CTP_THEME Mocha
            case macchiato
                set -Ux WEZTERM_CTP_THEME Macchiato
            case frappe
                set -Ux WEZTERM_CTP_THEME Frappe
            case latte
                set -Ux WEZTERM_CTP_THEME Latte
            case "*"
                echo "theme not recognized"
        end
    end

    function cpr
        if test -z "$argv[1]"
            g++ "$PWD/main.cpp" && $PWD/a.out
        else
            g++ "$argv[1]" && $PWD/a.out
        end
    end
end

function init
    starship init fish | source
    zoxide init fish | source
end

function envars
    set fzf_preview_dir_cmd exa --all --color=always --icons
end


paths
envars
aliases
init
funcs

# pnpm
set -gx PNPM_HOME /Users/hayesdombroski/Library/pnpm
set -gx PATH "$PNPM_HOME" $PATH
# pnpm end



# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
if test -f /opt/homebrew/Caskroom/miniconda/base/bin/conda
    eval /opt/homebrew/Caskroom/miniconda/base/bin/conda "shell.fish" hook $argv | source
else
    if test -f "/opt/homebrew/Caskroom/miniconda/base/etc/fish/conf.d/conda.fish"
        . "/opt/homebrew/Caskroom/miniconda/base/etc/fish/conf.d/conda.fish"
    else
        set -x PATH /opt/homebrew/Caskroom/miniconda/base/bin $PATH
    end
end
# <<< conda initialize <<<


# bun
set --export BUN_INSTALL "$HOME/.bun"
set --export PATH $BUN_INSTALL/bin $PATH

I tried fixing the issue myself, here is my Nix config:

{
  description = "Example Darwin system flake";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nix-darwin.url = "github:LnL7/nix-darwin";
    nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs@{ self, nix-darwin, nixpkgs }:
  let
    configuration = { pkgs, ... }: {
      # List packages installed in system profile. To search by name, run:
      # $ nix-env -qaP | grep wget
      environment.systemPackages =
        [ pkgs.vim pkgs.fish pkgs.neovim ];

      # Auto upgrade nix package and the daemon service.
      services.nix-daemon.enable = true;
      # nix.package = pkgs.nix;

      # Necessary for using flakes on this system.
      nix.settings.experimental-features = "nix-command flakes";

      # Create /etc/zshrc that loads the nix-darwin environment.
      programs.zsh.enable = true;
      programs.fish.enable = true;

      environment.shells = [ pkgs.bashInteractive pkgs.zsh pkgs.fish ]

      # Set Git commit hash for darwin-version.
      system.configurationRevision = self.rev or self.dirtyRev or null;

      # Used for backwards compatibility, please read the changelog before changing.
      # $ darwin-rebuild changelog
      system.stateVersion = 4;

      # The platform the configuration will be used on.
      nixpkgs.hostPlatform = "aarch64-darwin";
    };
  in
  {
    # Build darwin flake using:
    # $ darwin-rebuild build --flake .#simple
    darwinConfigurations."hayes" = nix-darwin.lib.darwinSystem {
      modules = [ configuration ];
    };

    # Expose the package set, including overlays, for convenience.
    darwinPackages = self.darwinConfigurations."hayes".pkgs;
  };
}

I have no idea what I am doing, thanks for the help!

@limoges
Copy link

limoges commented Feb 26, 2024

Re-open your shell again after running your commands. Let us know if it works.

@BlueFalconHD
Copy link
Author

@limoges It doesn't

@Samasaur1
Copy link
Contributor

After an install, the bare command should be darwin-rebuild, not nix-darwin. If that doesn't work, can you post the exact command you are trying to run and the output you get?

@zkourouma
Copy link

zkourouma commented Apr 15, 2024

running into the same issue here. i can run the nix-darwin command from nix, but no luck on where darwin-rebuild should be defined even after reloading my shell

❯ nix run nix-darwin -- switch --flake ~/.config/nix-darwin
building the system configuration...
user defaults...
setting up user launchd services...
setting up /Applications/Nix Apps...
setting up pam...
applying patches...
setting up /etc...
system defaults...
setting up launchd services...
reloading nix-daemon...
waiting for nix-daemon
waiting for nix-daemon
configuring networking...
setting nvram variables...

edit: more context

there's also no ~/.nix-defexpr/darwin only channels and channels_root and the ~/.nix-profile is a dangling symlink (if that matters)

@zkourouma
Copy link

it looks like this is an issue with nix-darwin and the fish shell in particular

this workaround fixed it for me: #122 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants