Closed mrjones2014 closed 3 months ago
Hmm, I wasn't able to test according to the How to test
section. @mrjones2014 could you help me walk through the use case as someone who just installed nix on their Mac OS machine?
Hmm, I wasn't able to test according to the
How to test
section. @mrjones2014 could you help me walk through the use case as someone who just installed nix on their Mac OS machine?
Sure thing, I'll send you a message on slack 👍
Just pushed a cool commit that validates the plugins
option and gives an error message if the user specified a package that isn't a supported Shell Plugin
Functionally tested as a new Nix user on Mac:
bash-3.2$ nix develop
(nix:Shell-with-Go-toolchain-env) Andis-MacBook-Pro:shell-plugins andititu$go version
go version go1.21.7 darwin/arm64
(nix:Shell-with-Go-toolchain-env) Andis-MacBook-Pro:shell-plugins andititu$ which go
/nix/store/b9wbj651hcyfm63kkcxykpjcqc0qqwp5-go-1.21.7/bin/go
Question: could we only have go and goals installed at the level of the shell-plugin directory, and then when I cd out of this directory, I don't have go installed anymore? From my understanding this is one possibility for Nix UX, right?
After running home-manager switch --flake .#mac
bash-3.2$ which aws
/Users/andititu/.nix-profile/bin/aws
bash-3.2$ aws organizations list-accounts
###############################################################################
# WARNING: 'aws' is not from the official registry. #
# Only proceed if you are the developer of 'aws'. #
# Otherwise, delete the file at /Users/andititu/.config/op/plugins/local/aws. #
###############################################################################
[ERROR] 2024/03/07 18:40:58 RequestDelegatedSession: cannot connect to 1Password app, make sure it is running
Question: could we only have go and goals installed at the level of the shell-plugin directory, and then when I cd out of this directory, I don't have go installed anymore? From my understanding this is how nix is working right?
Yep, that's the idea of Nix. I don't have any toolchains installed globally (like go
, gopls
, rustc
, cargo
, or anything like that); they get installed to temporary environments when I cd
into a project directory that has a flake.nix
(because I have nix-direnv
enabled, it automatically uses the flake.nix
when I cd
).
If you use direnv or nix-direnv (more optimized with extra caching for Nix stuff), you can create a .envrc
file with contents just use flake
, and then the Nix shell will be automatically set up when you cd
into the directory, and exited when you cd
out of the directory. Alternatively you can just manually run nix develop
which will start a subshell set up by the flake, only this way you will have to manually exit
the shell to get back to your main shell with the flake stuff gone. I have a component in my terminal prompt that tells me when I'm in a nix-shell
subshell, and whether its because of a direnv .envrc
:
Overview
The
flake.nix
added does two things:devShell
so Nix users can just runnix develop
or usedirenv
to have a Go environment set up to build the plugins.home-manager
module (users will choose one or the other) to configure 1Password Shell Plugins via Nix; this only works if you're using Nix to manage your shell config, but if you're deep into Nix enough to be using Flakes, you probably are managing your shell config with Nix, too.With this flake as an input to your own flake, you would then be able to configure 1Password Shell Plugins with the following:
Type of change
- [ ] Created a new plugin - [ ] Improved an existing plugin - [ ] Fixed a bug in an existing plugin - [x] Improved contributor utilities or experience ## Related Issue(s) * Resolves: # * Relates: # ## How To TestCreate a
home-manager
Nix flake that manages your shell configuration:flake.nix
./home.nix
If you're on macOS, you will need to install
home-manager
manually as well: https://nix-community.github.io/home-manager/index.xhtml#sec-install-standaloneOn NixOS, you can manage
home-manager
as a NixOS module instead.For standalone
home-manage
installation, runhome-manager switch --flake ~/path/to/flake-directory/.#my-config
to apply the configuration. If you're on NixOS and using a flake to managehome-manager
as a NixOS module, you can just runsudo nixos-rebuild switch --flake ~/path/to/flake-directory/.#my-config
Changelog
Add a `flake.nix` that provides a `devShell` for contributors as well as a NixOS and `home-manager` module that can be used to configure 1Password Shell Plugins via Nix.