atuin icon indicating copy to clipboard operation
atuin copied to clipboard

Add nix files and install instructions

Open Sciencentistguy opened this issue 2 years ago • 3 comments

Add a flake.nix to facilitate easier development on NixOS, and to allow atuin to be installed using nix profile. Also add a nix section to the install instructions in the readme

Sciencentistguy avatar Jul 11 '22 09:07 Sciencentistguy

Ignorant question: I know very little about Nix. What's special about this compared to nixpkgs?

conradludgate avatar Jul 11 '22 17:07 conradludgate

The primary benefit of this is that on nixos, I can run nix develop and get a shell with rustc, cargo etc (generally you don't install dev tools system-wide on nixos, you use devshells). As a side effect, one can nix profile install this repo to get a git version of atuin, rather than having to wait for a release.

Sciencentistguy avatar Jul 11 '22 17:07 Sciencentistguy

Hey! Thanks for the work here 🚀

Totally happy to get this merged if you could fix up the whitespace changes? The diff is a bit noisy

ellie avatar Sep 07 '22 09:09 ellie

I'd be happy to clean this up if you wanted merge this, I also use Nix and occasionally contribute to nixpkgs.

I will say though, that any user of NixOS (which I am) can always install the necessary build dependencies with nix develop nixpkgs#atuin which uses the deps that are maintained in https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/misc/atuin/default.nix.

As an example of what it can be used for, Helix uses it quite extensively to setup identical dev environments with a number of extra tools. The benefits to adding it to the atuin repo is mainly that Nix users could have tools like rustfmt and clippy automatically added to their environments, and as above, it makes it easy for a Nix user to install it from git.

arcuru avatar Oct 18 '22 18:10 arcuru

I'd be happy to clean this up if you wanted merge this, I also use Nix and occasionally contribute to nixpkgs.

yes please @patricksjackson, that would be fantastic!

ellie avatar Nov 02 '22 20:11 ellie

I've cleaned the diffspam in the readme :slightly_smiling_face:

Sciencentistguy avatar Nov 03 '22 23:11 Sciencentistguy

Those clippy warnings are not me - they happen on current main as well

Sciencentistguy avatar Nov 04 '22 00:11 Sciencentistguy

Thank you! Yeah don't worry they're just because there's a new Rust out

ellie avatar Nov 04 '22 10:11 ellie

@Sciencentistguy I'm seeing this error on my Macbook. Should it have worked?

~/Code/github.com/ellie/atuin (nix-flake)> nix build --show-trace
error: attribute 'frameworks' missing

       at /nix/store/vi5q2wxjmvff8al9d54cpi7qmvp99xf1-source/flake.nix:16:18:

           15|       packages.atuin = pkgs.callPackage ./atuin.nix {
           16|         inherit (pkgs.darwin.frameworks) Security SystemConfiguration;
             |                  ^
           17|       };

       … while evaluating the attribute 'darwin.frameworks'
...

charego avatar Nov 18 '22 17:11 charego

Considering flakes are technically experimental and will be for the foreseeable future, it's probably a good idea to add a backwards compatible shell.nix using flake-compat.

In addition, adding a note somewhere to the docs about how to enter the development shell would help let people know that it exists.

arcuru avatar Nov 18 '22 19:11 arcuru

@charego can you try replacing pkgs.darwin.frameworks with pkgs.darwin.apple_sdk.frameworks instead?

I don't have access to a Mac to confirm, but that should work.

arcuru avatar Nov 18 '22 20:11 arcuru

Sorry I keep responding in separate posts, but I'd also suggest adding a Github Action that runs nix flake check which would catch the frameworks issue pointed out by @charego, and maybe runs a simple nix build as well to make sure the pinned dependencies don't bitrot.

Adding caching with Cachix would be nice but probably not necessary yet.

arcuru avatar Nov 18 '22 20:11 arcuru

add a backwards compatible shell.nix using flake-compat @patricksjackson

flake-compat is obsolete since nix added builtins.getFlake:

(builtins.getFlake (toString ./.))
.devShells
.${builtins.currentSystem}
.default

Sciencentistguy avatar Nov 18 '22 21:11 Sciencentistguy

Oh interesting, I didn't know about builtins.getFlake.

But it's only available if flakes are enabled, so it doesn't work for writing a backwards compatible shell.nix: https://nixos.org/manual/nix/stable/language/builtins.html?#builtins-getFlake

arcuru avatar Nov 18 '22 23:11 arcuru