diff --git a/.gitignore b/.gitignore index 7f03765..124691c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /target /build +/result rust/target rust/build /build/linutil diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..fd86e53 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f7e97ef --- /dev/null +++ b/flake.nix @@ -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); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..078b9cc --- /dev/null +++ b/nix/default.nix @@ -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"; + }; +} diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..2d6e3ca --- /dev/null +++ b/nix/shell.nix @@ -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 "-----------------------------------" + ''; +}