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 Flake support #180

Merged
merged 3 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
## Table of Contents

- [📦 Installation](#-installation)
- [Nix](#nix)
- [Homebrew](#homebrew)
- [Cargo](#cargo)
- [Cargo BInstall](#cargo-binstall)
Expand Down Expand Up @@ -81,6 +82,14 @@

## 📦 Installation

### Nix
rossmacarthur marked this conversation as resolved.
Show resolved Hide resolved

This repository is a flake, and can be installed using nix profile:

```
nix profile install "github:rossmacarthur/sheldon"
```

### Homebrew

Sheldon can be installed using Homebrew.
Expand Down
8 changes: 8 additions & 0 deletions docs/src/Installation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# 📦 Installation

## Nix

This repository is a flake, and can be installed using nix profile:

```
nix profile install "github:rossmacarthur/sheldon"
```

## Homebrew

Sheldon can be installed using Homebrew.
Expand Down
85 changes: 85 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
in
with pkgs;
{
packages.sheldon = pkgs.callPackage ./sheldon.nix {
inherit (pkgs.darwin.apple_sdk.frameworks) Security;
};
packages.default = self.outputs.packages.${system}.sheldon;
defaultPackage = self.packages.${system}.sheldon;
devShells.default = mkShell {
buildInputs = [ rust-bin.stable.latest.default ];
};
}
);
}
38 changes: 38 additions & 0 deletions sheldon.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Sheldon package definition
#
# This file will be similar to the package definition in nixpkgs:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/sh/sheldon/package.nix
#
# Helpful documentation: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md
{
pkgs,
lib,
stdenv,
installShellFiles,
rustPlatform,
Security,
}:
rustPlatform.buildRustPackage {
name = "sheldon";

src = lib.cleanSource ./.;

cargoLock = {
lockFile = ./Cargo.lock;
# Allow dependencies to be fetched from git and avoid having to set the outputHashes manually
allowBuiltinFetchGit = true;
};

nativeBuildInputs = [installShellFiles];

buildInputs = [ pkgs.openssl pkgs.curl ] ++ lib.optionals stdenv.isDarwin [Security];

doCheck = false;

meta = with lib; {
description = "Fast, configurable, shell plugin manager";
homepage = "https://github.com/rossmacarthur/sheldon";
license = licenses.mit;
mainProgram = "sheldon";
};
}