diff --git a/.gitignore b/.gitignore index 8bbea60..18226e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .direnv -default/flake.lock +*/*.lock diff --git a/c/.envrc b/c/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/c/.envrc @@ -0,0 +1 @@ +use flake diff --git a/c/.gitignore b/c/.gitignore new file mode 100644 index 0000000..c460ab0 --- /dev/null +++ b/c/.gitignore @@ -0,0 +1,9 @@ +.direnv +.pre-commit-config.yaml +#Nix +result* +#Rust +target/ +#Python +__pycache__/ +*.py[cot] diff --git a/c/flake.nix b/c/flake.nix new file mode 100644 index 0000000..5e3b443 --- /dev/null +++ b/c/flake.nix @@ -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; + }; + }; + + }; + }; +} diff --git a/default/flake.nix b/default/flake.nix index bedd7b4..d5a3b1a 100644 --- a/default/flake.nix +++ b/default/flake.nix @@ -8,7 +8,6 @@ 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 = @@ -16,7 +15,6 @@ inputs.flake-parts.lib.mkFlake { inherit inputs; } { imports = [ inputs.devshell.flakeModule - inputs.nci.flakeModule inputs.pre-commit-hooks.flakeModule inputs.treefmt-nix.flakeModule ]; @@ -41,9 +39,6 @@ pre-commit.settings.hooks = { treefmt.enable = true; - deadnix.enable = true; - statix.enable = true; - shellcheck.enable = true; }; devshells.default = { packages = with pkgs; [ @@ -77,24 +72,12 @@ nixfmt.enable = true; rustfmt.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} - # ''; - # }); }; }; } diff --git a/flake.nix b/flake.nix index fad4eea..6ea1b12 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,14 @@ path = ./default; description = "Basic flake template"; }; + rust = { + path = ./rust; + description = "Flake template for rust projects"; + }; + c = { + path = ./c; + description = "Flake template for c projects"; + }; }; }; } diff --git a/rust/.envrc b/rust/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/rust/.envrc @@ -0,0 +1 @@ +use flake diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 0000000..c460ab0 --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1,9 @@ +.direnv +.pre-commit-config.yaml +#Nix +result* +#Rust +target/ +#Python +__pycache__/ +*.py[cot] diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..7d75412 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "rust" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/rust/flake.nix b/rust/flake.nix new file mode 100644 index 0000000..9125144 --- /dev/null +++ b/rust/flake.nix @@ -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 ]; + }; + }; + }; + }; + }; +} diff --git a/rust/src/main.rs b/rust/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/rust/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}