meta: refactor repository

This commit is contained in:
Artur Manuel 2025-03-26 15:08:13 +00:00
commit 599fe1903f
Signed by: amadaluzia
SSH key fingerprint: SHA256:Zwg7gBuZyaG48ucAZneJwltiXu0+tJb7c3lYt9AYlLg
28 changed files with 276 additions and 136 deletions

1
templates/rust/.envrc Normal file
View file

@ -0,0 +1 @@
use flake .#

View file

@ -3,5 +3,5 @@
version = 3
[[package]]
name = "rust-app"
version = "0.1.0"
name = "CHANGE_NAME"
version = "CHANGE_VER"

View file

@ -1,6 +1,6 @@
[package]
name = "rust-app"
version = "0.1.0"
name = "CHANGE_NAME"
version = "CHANGE_VER"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1733212471,
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
"lastModified": 1742889210,
"narHash": "sha256-hw63HnwnqU3ZQfsMclLhMvOezpM7RSB0dMAtD5/sOiw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
"rev": "698214a32beb4f4c8e3942372c694f40848b360d",
"type": "github"
},
"original": {
@ -16,43 +16,24 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1728538411,
"narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust": "rust"
"systems": "systems"
}
},
"rust": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"systems": {
"locked": {
"lastModified": 1733279627,
"narHash": "sha256-NCNDAGPkdFdu+DLErbmNbavmVW9AwkgP7azROFFSB0U=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "4da5a80ef76039e80468c902f1e9f5c0eab87d96",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}

View file

@ -1,45 +1,25 @@
{
description = "Rust Developer Environment";
description = "CHANGE DESC";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust.url = "github:oxalica/rust-overlay";
systems.url = "github:nix-systems/default";
};
outputs = {
self,
nixpkgs,
rust,
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in {
packages = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust)
];
};
inherit system;
outputs = { self, nixpkgs, systems, }:
let
pkgsFor = nixpkgs.legacyPackages;
forAllSystems = f:
nixpkgs.lib.genAttrs (import systems)
(system: f system pkgsFor.${system});
in {
rust-app = pkgs.callPackage ./nix/package.nix {};
default = self.packages.${system}.rust-app;
});
packages = forAllSystems (system: pkgs: {
default = pkgs.callPackage ./nix/package.nix { };
CHANGE_NAME = self.packages.${system}.default;
});
devShells = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust)
];
};
inherit system;
in {
default = pkgs.callPackage ./nix/shell.nix {
inherit (self.packages.${system}) rust-app;
};
});
};
devShells = forAllSystems
(_: pkgs: { default = pkgs.callPackage ./nix/shell.nix { }; });
formatter =
forAllSystems (_: pkgs: pkgs.callPackage ./nix/formatter.nix { });
};
}

View file

@ -0,0 +1,10 @@
{ writeShellApplication, fd, nixfmt, deadnix, statix, rustfmt }:
writeShellApplication {
name = "liner";
runtimeInputs = [ fd nixfmt deadnix statix rustfmt ];
text = ''
fd -e nix -X nixfmt {} \; -X deadnix -e {} \;
fd -e nix -x statix fix {} \;
fd -e rs -X rustfmt {} \;
'';
}

View file

@ -1,6 +1,7 @@
{ rustPlatform }: let
pname = "rust-app";
version = "0.1.0";
{ rustPlatform }:
let
pname = "CHANGE_NAME";
version = "CHANGE_VER";
in rustPlatform.buildRustPackage {
inherit pname version;
src = ../.;

View file

@ -1,8 +1,5 @@
{ mkShell, rust-app, rust-bin }:
{ mkShell, rustc, cargo, nixfmt, deadnix, statix, rustfmt, clippy }:
mkShell {
name = "Rust Rivers";
inputsFrom = [ rust-app ];
buildInputs = [
rust-bin.stable.latest.default
];
name = "rust";
packages = [ nixfmt deadnix statix rustfmt clippy rustc cargo ];
}