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

Add nix files and install instructions #477

Merged
merged 1 commit into from Feb 15, 2023

Conversation

Sciencentistguy
Copy link
Contributor

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

@conradludgate
Copy link
Collaborator

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

@Sciencentistguy
Copy link
Contributor Author

Sciencentistguy commented Jul 11, 2022

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.

@ellie
Copy link
Member

ellie commented Sep 7, 2022

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

@arcuru
Copy link
Sponsor Contributor

arcuru commented Oct 18, 2022

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.

@ellie
Copy link
Member

ellie commented Nov 2, 2022

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!

@Sciencentistguy
Copy link
Contributor Author

I've cleaned the diffspam in the readme 🙂

@Sciencentistguy
Copy link
Contributor Author

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

@ellie
Copy link
Member

ellie commented Nov 4, 2022

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

ellie
ellie previously approved these changes Nov 4, 2022
@charego
Copy link
Contributor

charego commented Nov 18, 2022

@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'
...

@arcuru
Copy link
Sponsor Contributor

arcuru commented Nov 18, 2022

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
Copy link
Sponsor Contributor

arcuru commented Nov 18, 2022

@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
Copy link
Sponsor Contributor

arcuru commented Nov 18, 2022

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.

@Sciencentistguy
Copy link
Contributor Author

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

@arcuru
Copy link
Sponsor Contributor

arcuru commented Nov 18, 2022

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

Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I'm happy to get this in as-is, even if there's a little more we could do. Thanks for the work @Sciencentistguy <3

@ellie ellie merged commit b2a0986 into atuinsh:main Feb 15, 2023
@0x4A6F 0x4A6F mentioned this pull request Feb 28, 2023
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

Successfully merging this pull request may close these issues.

None yet

5 participants