feat: split templates

This commit is contained in:
Patrick 2024-11-22 14:20:25 +01:00
parent cd4ba26eed
commit 4d1d10d994
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
11 changed files with 231 additions and 21 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
.direnv .direnv
default/flake.lock */*.lock

1
c/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

9
c/.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
.direnv
.pre-commit-config.yaml
#Nix
result*
#Rust
target/
#Python
__pycache__/
*.py[cot]

87
c/flake.nix Normal file
View file

@ -0,0 +1,87 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devshell.flakeModule
inputs.pre-commit-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];
systems = [
"x86_64-linux"
"aarch64-linux"
];
perSystem =
{
config,
pkgs,
system,
...
}:
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
pre-commit.settings.hooks = {
treefmt.enable = true;
};
devshells.default = {
imports = [ "${inputs.devshell}/extra/language/c.nix" ];
language.c = {
includes = [
pkgs.libelf
];
libraries = [
pkgs.libelf
];
};
packages = with pkgs; [
hello
config.treefmt.build.wrapper
(python3.withPackages (p: with p; [ tqdm ]))
];
commands = [
{
package = pkgs.nix;
help = "nichts";
}
];
env = [
{
name = "TEST";
value = "TSET";
}
];
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
};
treefmt = {
projectRootFile = "flake.nix";
programs = {
clang-format.enable = true;
cmake-format.enable = true;
nixfmt.enable = true;
deadnix.enable = true;
statix.enable = true;
shellcheck.enable = true;
};
};
};
};
}

View file

@ -8,7 +8,6 @@
pre-commit-hooks.url = "github:cachix/git-hooks.nix"; pre-commit-hooks.url = "github:cachix/git-hooks.nix";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.url = "github:numtide/treefmt-nix";
nci.url = "github:yusdacra/nix-cargo-integration";
}; };
outputs = outputs =
@ -16,7 +15,6 @@
inputs.flake-parts.lib.mkFlake { inherit inputs; } { inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ imports = [
inputs.devshell.flakeModule inputs.devshell.flakeModule
inputs.nci.flakeModule
inputs.pre-commit-hooks.flakeModule inputs.pre-commit-hooks.flakeModule
inputs.treefmt-nix.flakeModule inputs.treefmt-nix.flakeModule
]; ];
@ -41,9 +39,6 @@
pre-commit.settings.hooks = { pre-commit.settings.hooks = {
treefmt.enable = true; treefmt.enable = true;
deadnix.enable = true;
statix.enable = true;
shellcheck.enable = true;
}; };
devshells.default = { devshells.default = {
packages = with pkgs; [ packages = with pkgs; [
@ -77,24 +72,12 @@
nixfmt.enable = true; nixfmt.enable = true;
rustfmt.enable = true; rustfmt.enable = true;
typstfmt.enable = true; typstfmt.enable = true;
deadnix.enable = true;
statix.enable = true;
shellcheck.enable = true;
}; };
}; };
# Rust
#nci.projects.main = {
# path = ./.;
# numtideDevshell = "default";
#};
#nci.crates.main = { };
# devShells.default = config.nci.outputs.main.devShell.overrideAttrs (old: {
# nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.cargo-release ];
#
# shellHook = ''
# ${old.shellHook or ""}
# ${config.pre-commit.installationScript}
# '';
# });
}; };
}; };
} }

View file

@ -7,6 +7,14 @@
path = ./default; path = ./default;
description = "Basic flake template"; description = "Basic flake template";
}; };
rust = {
path = ./rust;
description = "Flake template for rust projects";
};
c = {
path = ./c;
description = "Flake template for c projects";
};
}; };
}; };
} }

1
rust/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

9
rust/.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
.direnv
.pre-commit-config.yaml
#Nix
result*
#Rust
target/
#Python
__pycache__/
*.py[cot]

6
rust/Cargo.toml Normal file
View file

@ -0,0 +1,6 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"
[dependencies]

103
rust/flake.nix Normal file
View file

@ -0,0 +1,103 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
nci.url = "github:yusdacra/nix-cargo-integration";
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devshell.flakeModule
inputs.nci.flakeModule
inputs.pre-commit-hooks.flakeModule
inputs.treefmt-nix.flakeModule
];
systems = [
"x86_64-linux"
"aarch64-linux"
];
perSystem =
{
config,
pkgs,
system,
...
}:
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
pre-commit.settings.hooks = {
treefmt.enable = true;
};
devshells.default = {
packages = with pkgs; [
hello
config.treefmt.build.wrapper
(python3.withPackages (p: with p; [ tqdm ]))
];
commands = [
{
package = pkgs.nix;
help = "nichts";
}
];
env = [
{
name = "TEST";
value = "TSET";
}
];
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
};
treefmt = {
projectRootFile = "flake.nix";
programs = {
deadnix.enable = true;
statix.enable = true;
shellcheck.enable = true;
beautysh.enable = true;
nixfmt.enable = true;
rustfmt.enable = true;
};
};
# Rust
nci.projects.main = {
path = ./.;
numtideDevshell = "default";
};
nci.crates.main = rec {
#runtimeLibs = with pkgs; [
#];
depsDrvConfig = {
mkDerivation = {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
alsa-lib
];
};
};
drvConfig = {
mkDerivation = {
inherit (depsDrvConfig.mkDerivation) buildInputs;
nativeBuildInputs = [ pkgs.pkg-config ];
};
};
};
};
};
}

3
rust/src/main.rs Normal file
View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}