Skip to content

Commit b6ca0dc

Browse files
authored
feat(nix): create a flake (ChrisTitusTech#1154)
turns out i use nixos now so this will make the development process wayyyy easier for me you can now build linutil for nix with `nix build`, enter the dev environment with `nix develop`, and format nix code with `nix fmt` and if some crazy person was to use linutil on nixos, now they can with `nix run github:ChrisTitusTech/linutil` or by adding linutil to their flake
1 parent a674cc1 commit b6ca0dc

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/target
22
/build
3+
/result
34
rust/target
45
rust/build
56
/build/linutil

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
description = "Distro-agnostic toolbox designed to simplify everyday Linux tasks";
3+
4+
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
5+
6+
outputs =
7+
{ self, nixpkgs }:
8+
let
9+
systems = [
10+
"x86_64-linux"
11+
"aarch64-linux"
12+
];
13+
14+
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
15+
in
16+
{
17+
packages = forAllSystems (pkgs: {
18+
default = pkgs.callPackage ./nix/default.nix { };
19+
});
20+
21+
devShells = forAllSystems (pkgs: {
22+
default = pkgs.callPackage ./nix/shell.nix { inherit pkgs; };
23+
});
24+
25+
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
26+
};
27+
}

nix/default.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
lib,
3+
rustPlatform,
4+
}:
5+
6+
let
7+
p = (lib.importTOML ../Cargo.toml).workspace.package;
8+
pTUI = (lib.importTOML ../tui/Cargo.toml).package;
9+
in
10+
rustPlatform.buildRustPackage {
11+
pname = "linutil";
12+
inherit (p) version;
13+
14+
src = ../.;
15+
16+
cargoLock.lockFile = ../Cargo.lock;
17+
18+
meta = {
19+
inherit (pTUI) description;
20+
homepage = pTUI.documentation;
21+
license = lib.licenses.mit;
22+
maintainers = with lib.maintainers; [ adamperkowski ];
23+
mainProgram = "linutil";
24+
};
25+
}

nix/shell.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{ pkgs }:
2+
3+
let
4+
mainPkg = if builtins.pathExists ./default.nix then pkgs.callPackage ./default.nix { } else { };
5+
6+
pkgInputs =
7+
with pkgs;
8+
[
9+
clippy
10+
rustfmt
11+
rust-analyzer
12+
bash-language-server
13+
checkbashisms
14+
shellcheck
15+
typos
16+
vhs
17+
]
18+
++ (mainPkg.nativeBuildInputs or [ ])
19+
++ (mainPkg.buildInputs or [ ]);
20+
in
21+
pkgs.mkShell {
22+
packages = pkgInputs;
23+
24+
shellHook = ''
25+
echo -ne "-----------------------------------\n "
26+
27+
echo -n "${toString (map (pkg: "• ${pkg.name}\n") pkgInputs)}"
28+
29+
echo "-----------------------------------"
30+
'';
31+
}

0 commit comments

Comments
 (0)