From a0ee1fe054b90e348ed817aff3209b3ad33b46ca Mon Sep 17 00:00:00 2001 From: Isabel Date: Sat, 25 May 2024 18:00:02 +0100 Subject: [PATCH] feat: nix flake (#1) --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 25 +++++++++++++++++++++++++ nix/default.nix | 26 ++++++++++++++++++++++++++ nix/shell.nix | 16 ++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/default.nix create mode 100644 nix/shell.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..089a9ba --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1716509168, + "narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "bfb7a882678e518398ce9a31a881538679f6f092", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9de4fea --- /dev/null +++ b/flake.nix @@ -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 { }; + }); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..beb7f7d --- /dev/null +++ b/nix/default.nix @@ -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"; + }; +} diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..ebf3301 --- /dev/null +++ b/nix/shell.nix @@ -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 [ ]); +})