diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..e3fecb3 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +use flake + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4b75299 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1775036866, + "narHash": "sha256-ZojAnPuCdy657PbTq5V0Y+AHKhZAIwSIT2cb8UgAz/U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6201e203d09599479a3b3450ed24fa81537ebc4e", + "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..0f9bf25 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + description = "Rust Project Template"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; + + outputs = { + self, + nixpkgs, + }: let + systems = ["x86_64-linux" "aarch64-linux"]; + forEachSystem = nixpkgs.lib.genAttrs systems; + pkgsForEach = nixpkgs.legacyPackages; + in { + packages = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/package.nix {}; + }); + + devShells = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; + }); + + hydraJobs = self.packages; + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..3fcf1c2 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,30 @@ +{ + lib, + rustPlatform, +}: +rustPlatform.buildRustPackage { + pname = "lychee"; + version = "1.0.0"; + + src = let + fs = lib.fileset; + s = ../.; + in + fs.toSource { + root = s; + fileset = fs.unions [ + (s + /crates) + (s + /Cargo.lock) + (s + /Cargo.toml) + ]; + }; + + cargoLock.lockFile = ../Cargo.lock; + enableParallelBuilding = true; + + meta = { + description = "Simple, opinionated image viewer for Wayland"; + maintainers = with lib.maintainers; [NotAShelf]; + license = lib.licenses.mpl20; + }; +} diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..b7e49d8 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,33 @@ +{ + lib, + mkShell, + cargo, + rustfmt, + clippy, + taplo, + pkg-config, + wayland, + libxkbcommon, +}: let + runtimeDeps = [ + libxkbcommon + wayland + ]; +in + mkShell { + name = "rust"; + + strictDeps = true; + nativeBuildInputs = [ + pkg-config + + cargo + clippy + (rustfmt.override {asNightly = true;}) + taplo + ]; + + buildInputs = runtimeDeps; + + env.LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${lib.makeLibraryPath runtimeDeps}"; + } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 311ce21..0000000 --- a/shell.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - pkgs ? import {}, - lib ? pkgs.lib, -}: -pkgs.mkShell rec { - buildInputs = with pkgs; [ - libxkbcommon - wayland - pkg-config - ]; - - shellHook = '' - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${lib.makeLibraryPath buildInputs}"; - ''; -}