Add flake

This commit is contained in:
Michael Zhang 2023-01-31 13:17:07 -06:00
parent 544b2a0652
commit 0c1e7da1ae
5 changed files with 141 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
**/*.rs.bk
shiet.*
/v*.tar.gz
.direnv
/result*

12
default.nix Normal file
View file

@ -0,0 +1,12 @@
{ toolchain, makeRustPlatform, pkg-config }:
let rustPlatform = makeRustPlatform { inherit (toolchain) cargo rustc; };
in rustPlatform.buildRustPackage {
name = "liveterm";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [ pkg-config ];
buildInputs = [ ];
}

93
flake.lock Normal file
View file

@ -0,0 +1,93 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1675146246,
"narHash": "sha256-upQtcca/sThA5Jkmn5pDaYFoCmPLMyv7bGFCZFcVhqM=",
"owner": "nix-community",
"repo": "fenix",
"rev": "97deb5c86b238c2a000ef4eb92fb40465f086706",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"id": "flake-utils",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1674641431,
"narHash": "sha256-qfo19qVZBP4qn5M5gXc/h1MDgAtPA5VxJm9s8RUAkVk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9b97ad7b4330aacda9b2343396eb3df8a853b4fc",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1667629849,
"narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3bacde6273b09a21a8ccfba15586fb165078fb62",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"fenix": "fenix",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1675097868,
"narHash": "sha256-BKFLjEzdoFWso7Artln7djf8RbtBynj9wZKIj22LV5g=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "b75803ad31772d105d86f8ebee0cbc8844a4fa29",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

33
flake.nix Normal file
View file

@ -0,0 +1,33 @@
{
inputs = { fenix.url = "github:nix-community/fenix"; };
outputs = { self, nixpkgs, flake-utils, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};
toolchain = pkgs.fenix.stable;
flakePkgs = { leanshot = pkgs.callPackage ./. { inherit toolchain; }; };
in rec {
packages = flake-utils.lib.flattenTree flakePkgs;
defaultPackage = packages.leanshot;
devShell = pkgs.mkShell {
inputsFrom = with packages; [ leanshot ];
packages = (with pkgs; [ cargo-watch cargo-deny cargo-edit ])
++ (with toolchain; [ cargo rustc rustfmt ]);
CARGO_UNSTABLE_SPARSE_REGISTRY = "true";
PKG_CONFIG_PATH = let
standardPkgs = pkgs.lib.makeSearchPathOutput "dev" "lib/pkgconfig"
(with pkgs; [ libGL xorg.libX11 ]);
otherPkgs = pkgs.lib.makeSearchPath "pkgconfig"
(with pkgs; [ "${xorg.xorgproto}/share" ]);
in "${standardPkgs}:${otherPkgs}";
};
});
}