feat(nix): create a flake (#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
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/target
|
||||
/build
|
||||
/result
|
||||
rust/target
|
||||
rust/build
|
||||
/build/linutil
|
||||
|
||||
Generated
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1760284886,
|
||||
"narHash": "sha256-TK9Kr0BYBQ/1P5kAsnNQhmWWKgmZXwUQr4ZMjCzWf2c=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "cf3f5c4def3c7b5f1fc012b3d839575dbe552d43",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
description = "Distro-agnostic toolbox designed to simplify everyday Linux tasks";
|
||||
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (pkgs: {
|
||||
default = pkgs.callPackage ./nix/default.nix { };
|
||||
});
|
||||
|
||||
devShells = forAllSystems (pkgs: {
|
||||
default = pkgs.callPackage ./nix/shell.nix { inherit pkgs; };
|
||||
});
|
||||
|
||||
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
lib,
|
||||
rustPlatform,
|
||||
}:
|
||||
|
||||
let
|
||||
p = (lib.importTOML ../Cargo.toml).workspace.package;
|
||||
pTUI = (lib.importTOML ../tui/Cargo.toml).package;
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "linutil";
|
||||
inherit (p) version;
|
||||
|
||||
src = ../.;
|
||||
|
||||
cargoLock.lockFile = ../Cargo.lock;
|
||||
|
||||
meta = {
|
||||
inherit (pTUI) description;
|
||||
homepage = pTUI.documentation;
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ adamperkowski ];
|
||||
mainProgram = "linutil";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{ pkgs }:
|
||||
|
||||
let
|
||||
mainPkg = if builtins.pathExists ./default.nix then pkgs.callPackage ./default.nix { } else { };
|
||||
|
||||
pkgInputs =
|
||||
with pkgs;
|
||||
[
|
||||
clippy
|
||||
rustfmt
|
||||
rust-analyzer
|
||||
bash-language-server
|
||||
checkbashisms
|
||||
shellcheck
|
||||
typos
|
||||
vhs
|
||||
]
|
||||
++ (mainPkg.nativeBuildInputs or [ ])
|
||||
++ (mainPkg.buildInputs or [ ]);
|
||||
in
|
||||
pkgs.mkShell {
|
||||
packages = pkgInputs;
|
||||
|
||||
shellHook = ''
|
||||
echo -ne "-----------------------------------\n "
|
||||
|
||||
echo -n "${toString (map (pkg: "• ${pkg.name}\n") pkgInputs)}"
|
||||
|
||||
echo "-----------------------------------"
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user