Skip to content

Commit

Permalink
feat: nix flake (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed May 25, 2024
1 parent 7415ade commit a0ee1fe
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
27 changes: 27 additions & 0 deletions flake.lock

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

25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

outputs =
{ nixpkgs, ... }:
let
forAllSystems =
function:
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
system: function nixpkgs.legacyPackages.${system}
);
in
{
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);

devShells = forAllSystems (pkgs: {
default = pkgs.callPackage ./nix/shell.nix { };
});

packages = forAllSystems (pkgs: rec {
default = purr;
purr = pkgs.callPackage ./nix/default.nix { };
});
};
}
26 changes: 26 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
lib,
rustPlatform,
pkg-config,
openssl,
stdenv,
darwin,
}:
rustPlatform.buildRustPackage {
pname = "purr";
inherit ((lib.importTOML ../Cargo.toml).package) version;

src = ../.;
cargoLock.lockFile = ../Cargo.lock;

nativeBuildInputs = [ pkg-config ];

buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];

meta = with lib; {
description = "Utility commands for managing userstyles";
homepage = "https://github.com/uncenter/purr";
license = licenses.mit;
mainProgram = "purr";
};
}
16 changes: 16 additions & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
clippy,
rustfmt,
callPackage,
rust-analyzer,
}:
let
mainPkg = callPackage ./default.nix { };
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs = [
clippy
rustfmt
rust-analyzer
] ++ (oa.nativeBuildInputs or [ ]);
})

0 comments on commit a0ee1fe

Please sign in to comment.