diff --git a/.gitignore b/.gitignore index 9d50ca2d96f..d934a9f4d29 100644 --- a/.gitignore +++ b/.gitignore @@ -128,6 +128,10 @@ compile_commands.json .cache/ dbc_extract3/cache/live/DBCache.bin dbc_extract3/cache/ptr/DBCache.bin +.direnv +.envrc +result +.pre-commit-config.yaml apikey.txt diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000000..d59d3ec63c5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,142 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1772893680, + "narHash": "sha256-JDqZMgxUTCq85ObSaFw0HhE+lvdOre1lx9iI6vYyOEs=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "8baab586afc9c9b57645a734c820e4ac0a604af9", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1773597492, + "narHash": "sha256-hQ284SkIeNaeyud+LS0WVLX+WL2rxcVZLFEaK0e03zg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a07d4ce6bee67d7c838a8a5796e75dff9caa21ef", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1773297127, + "narHash": "sha256-6E/yhXP7Oy/NbXtf1ktzmU8SdVqJQ09HC/48ebEGBpk=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "71b125cd05fbfd78cab3e070b73544abe24c5016", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000000..7727644aef9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,96 @@ +{ + description = "simulationcraft"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + git-hooks = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + flake-utils, + treefmt-nix, + nixpkgs, + git-hooks, + self, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + treefmt = treefmt-nix.lib.evalModule pkgs (_: { + projectRootFile = "flake.nix"; + programs = { + actionlint.enable = true; + dockerfmt.enable = true; + nixfmt.enable = true; + }; + }); + + githooksEval = git-hooks.lib.${system}.run { + src = self; + hooks.treefmt = { + enable = true; + package = treefmt.config.build.wrapper; + }; + }; + + llvm = pkgs.llvmPackages_latest; + packages = with pkgs; [ + clang-tools + llvm.clang + llvm.lldb + qt6.qtbase + qt6.qtwebengine + ]; + + nbi = with pkgs; [ + pkg-config + curlFull + cmake + qt6.wrapQtAppsHook + ]; + + qtCmakePath = pkgs.symlinkJoin { + name = "qt6-cmake"; + paths = with pkgs.qt6; [ + qtbase + qtwebengine + ]; + }; + + rev = self.rev or "dirty"; + in + { + formatter = treefmt.config.build.wrapper; + devShells.default = pkgs.mkShell { + nativeBuildInputs = nbi; + packages = packages; + shellHook = '' + ${githooksEval.shellHook} + ''; + }; + + packages.simc = llvm.stdenv.mkDerivation { + pname = "simc"; + version = "1201.01.${rev}"; + src = self; + nativeBuildInputs = nbi; + buildInputs = packages; + sconsFlags = ""; + enableParallelBuilding = true; + cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${qtCmakePath}/lib/cmake" ]; + }; + packages.default = self.packages.${system}.simc; + } + ); +}