diff --git a/.gitignore b/.gitignore index d2f1ee13..de6d13d3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ packaging/conda/meta.yaml #nix .direnv/ +result # CLion diff --git a/flake.lock b/flake.lock index 0123ed03..c5276dea 100644 --- a/flake.lock +++ b/flake.lock @@ -2,7 +2,9 @@ "nodes": { "flake-parts": { "inputs": { - "nixpkgs-lib": "nixpkgs-lib" + "nixpkgs-lib": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1712014858, @@ -20,36 +22,15 @@ }, "nixpkgs": { "locked": { - "lastModified": 1712512205, - "narHash": "sha256-CrKKps0h7FoagRcE2LT3h/72Z64D0Oh83UF1XZVhCLQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "3c1b6f75344e207a67536d834886ee9b4577ebe7", - "type": "github" + "lastModified": 1712163089, + "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=", + "path": "/nix/store/n2g5cqwv8qf5p6vjxny6pg3blbdij12k-source", + "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5", + "type": "path" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-lib": { - "locked": { - "dir": "lib", - "lastModified": 1711703276, - "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", - "type": "github" - }, - "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "id": "nixpkgs", + "type": "indirect" } }, "root": { diff --git a/flake.nix b/flake.nix index 3358731b..6500bb0f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,33 +1,34 @@ { - description = "Description for the project"; + description = "C++ UML diagram generator based on Clang"; inputs = { - flake-parts.url = "github:hercules-ci/flake-parts"; - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "nixpkgs"; + + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; }; - outputs = inputs@{ flake-parts, ... }: - flake-parts.lib.mkFlake { inherit inputs; } { - imports = []; - systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; - perSystem = { config, self', inputs', pkgs, system, ... }: { + outputs = {flake-parts, ...} @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; - packages.default = config.packages.clang-uml; - packages.clang-uml = pkgs.callPackage packaging/nix/default.nix { }; + perSystem = { + self', + pkgs, + ... + }: { + packages = { + default = self'.packages.clang-uml; + clang-uml = pkgs.callPackage ./packaging/nix {}; + }; devShells.default = pkgs.mkShell { - packages = with pkgs; [ - # C++ Compiler is already part of stdenv - cmake - llvmPackages_latest.libllvm - yaml-cpp - ccache - elfutils - pkg-config - clang - libclang - ]; + inputsFrom = [self'.packages.clang-uml]; }; + + formatter = pkgs.alejandra; }; }; } diff --git a/packaging/nix/default.nix b/packaging/nix/default.nix index a632d101..b66794fb 100644 --- a/packaging/nix/default.nix +++ b/packaging/nix/default.nix @@ -1,34 +1,30 @@ -{ pkgs ? import {} }: - - -# Nix derivation for basic C++ project using clang -with pkgs; stdenv.mkDerivation { +{ + stdenv, + cmake, + pkg-config, + installShellFiles, + libclang, + libllvm, + yaml-cpp, +}: +stdenv.mkDerivation { name = "clang-uml"; src = ../..; - buildInputs = [ - clang - libclang + nativeBuildInputs = [ cmake - llvmPackages_latest.libllvm - yaml-cpp - ccache - elfutils pkg-config + installShellFiles ]; - dontUseCmakeConfigure = true; + buildInputs = [ + libclang + libllvm + yaml-cpp + ]; - buildPhase = "CCACHE_DIR=/build/.ccache make release"; - - installPhase = '' - mkdir -p $out/bin - cp release/src/clang-uml $out/bin/clang-uml + postInstall = '' + installShellCompletion --bash $src/packaging/autocomplete/clang-uml + installShellCompletion --zsh $src/packaging/autocomplete/_clang-uml ''; - - postInstall = " - installShellCompletion --cmd clang-uml \ - --zsh packaging/autocomplete/_clang-uml - --bach packaging/autocomplete/clang-uml - "; }