Skip to content

Commit

Permalink
Add Nix Flake support (#180)
Browse files Browse the repository at this point in the history
Fixes #160
  • Loading branch information
DoomHammer authored Jun 9, 2024
1 parent f469531 commit d0330e7
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 0 deletions.
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

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";
};
}

0 comments on commit d0330e7

Please sign in to comment.