nix: package with flakes; simplify devshell
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia37044debea91a1db3d944a0c74f66356a6a6964
This commit is contained in:
parent
530fc7cdc1
commit
0fc6b177cc
6 changed files with 115 additions and 15 deletions
2
.envrc
Normal file
2
.envrc
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
use flake
|
||||||
|
|
||||||
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
|
|
@ -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
|
||||||
|
}
|
||||||
23
flake.nix
Normal file
23
flake.nix
Normal file
|
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
30
nix/package.nix
Normal file
30
nix/package.nix
Normal file
|
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
33
nix/shell.nix
Normal file
33
nix/shell.nix
Normal file
|
|
@ -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}";
|
||||||
|
}
|
||||||
15
shell.nix
15
shell.nix
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
pkgs ? import <nixpkgs> {},
|
|
||||||
lib ? pkgs.lib,
|
|
||||||
}:
|
|
||||||
pkgs.mkShell rec {
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
libxkbcommon
|
|
||||||
wayland
|
|
||||||
pkg-config
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${lib.makeLibraryPath buildInputs}";
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue