From 50f7235fabe738ec95d25b3b92df749126374957 Mon Sep 17 00:00:00 2001 From: Denis Craig Date: Mon, 16 Mar 2026 21:05:35 +0000 Subject: [PATCH 1/6] Add nix flake --- .gitignore | 4 ++ flake.lock | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 94 +++++++++++++++++++++++++++++++++++ 3 files changed, 240 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix 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..b4d5f1a2844 --- /dev/null +++ b/flake.nix @@ -0,0 +1,94 @@ +{ + 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 + ]; + }; + in + { + formatter = treefmt.config.build.wrapper; + devShells.default = pkgs.mkShell { + nativeBuildInputs = nbi; + packages = packages; + shellHook = '' + ${githooksEval.shellHook} + ''; + }; + + packages.simc = llvm.stdenv.mkDerivation rec { + pname = "simc"; + version = "0.0.1"; + src = self; + nativeBuildInputs = nbi; + buildInputs = packages; + sconsFlags = ""; + enableParallelBuilding = true; + cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${qtCmakePath}/lib/cmake" ]; + }; + packages.default = self.packages.${system}.simc; + } + ); +} From 4e692d1a3206856c2cd026fdc828eba6991a6613 Mon Sep 17 00:00:00 2001 From: Denis Craig Date: Mon, 16 Mar 2026 21:38:29 +0000 Subject: [PATCH 2/6] Add git rev version to package --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index b4d5f1a2844..8b141b7d784 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,8 @@ qtwebengine ]; }; + + rev = self.rev or "dirty"; in { formatter = treefmt.config.build.wrapper; @@ -80,7 +82,7 @@ packages.simc = llvm.stdenv.mkDerivation rec { pname = "simc"; - version = "0.0.1"; + version = "1201.01.${rev}"; src = self; nativeBuildInputs = nbi; buildInputs = packages; From 9d6b8c61d3e3e1f6ca8ef49e4ce98f47e9b552cb Mon Sep 17 00:00:00 2001 From: Denis Craig Date: Wed, 18 Mar 2026 23:23:11 +0000 Subject: [PATCH 3/6] Remove recursive package config --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 8b141b7d784..7727644aef9 100644 --- a/flake.nix +++ b/flake.nix @@ -80,7 +80,7 @@ ''; }; - packages.simc = llvm.stdenv.mkDerivation rec { + packages.simc = llvm.stdenv.mkDerivation { pname = "simc"; version = "1201.01.${rev}"; src = self; From 07a64b6a378de08148eb883b99b0737742522498 Mon Sep 17 00:00:00 2001 From: Denis Craig Date: Wed, 25 Mar 2026 23:31:33 +0000 Subject: [PATCH 4/6] remove treefmt and git-hooks, create separate packages/devshells for gui --- flake.lock | 83 +----------------------------------------- flake.nix | 103 ++++++++++++++++++++++++----------------------------- 2 files changed, 47 insertions(+), 139 deletions(-) diff --git a/flake.lock b/flake.lock index d59d3ec63c5..1517f485600 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "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" @@ -34,49 +18,6 @@ "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, @@ -96,9 +37,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "git-hooks": "git-hooks", - "nixpkgs": "nixpkgs", - "treefmt-nix": "treefmt-nix" + "nixpkgs": "nixpkgs" } }, "systems": { @@ -115,26 +54,6 @@ "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", diff --git a/flake.nix b/flake.nix index 7727644aef9..063f3aa84a1 100644 --- a/flake.nix +++ b/flake.nix @@ -4,93 +4,82 @@ 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 + rev = self.rev or "dirty"; 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 ]; + qtPackages = + with pkgs; + [ + qt6.qtbase + qt6.qtwebengine + ] + ++ packages; + nbi = with pkgs; [ - pkg-config curlFull cmake - qt6.wrapQtAppsHook + pkg-config ]; - qtCmakePath = pkgs.symlinkJoin { - name = "qt6-cmake"; - paths = with pkgs.qt6; [ - qtbase - qtwebengine - ]; - }; - - rev = self.rev or "dirty"; + qtNbi = with pkgs; [ qt6.wrapQtAppsHook ] ++ nbi; in { - formatter = treefmt.config.build.wrapper; - devShells.default = pkgs.mkShell { - nativeBuildInputs = nbi; - packages = packages; - shellHook = '' - ${githooksEval.shellHook} - ''; + devShells = { + default = self.devShells.${system}.simc; + simc = pkgs.mkShell { + nativeBuildInputs = nbi; + packages = packages; + }; + + simcqt = pkgs.mkShell { + nativeBuildInputs = qtNbi; + packages = qtPackages; + }; }; - 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; + simc = llvm.stdenv.mkDerivation { + pname = "simc"; + version = "1201.01.${rev}"; + src = self; + nativeBuildInputs = nbi; + buildInputs = packages; + sconsFlags = ""; + enableParallelBuilding = true; + cmakeFlags = [ "-DBUILD_GUI=OFF" ]; + }; + + simcqt = llvm.stdenv.mkDerivation { + pname = "simcqt"; + version = "1201.01.${rev}"; + src = self; + nativeBuildInputs = qtNbi; + buildInputs = qtPackages; + sconsFlags = ""; + enableParallelBuilding = true; + cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${pkgs.qt6.qtbase}/lib/cmake" ]; + }; }; - packages.default = self.packages.${system}.simc; } ); } From 91ed0afc9a39077ee5531ae1006bfe5a9eea2099 Mon Sep 17 00:00:00 2001 From: Denis Craig Date: Wed, 25 Mar 2026 23:32:20 +0000 Subject: [PATCH 5/6] remove unused .pre-commit-config.yaml from .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index d934a9f4d29..a7b94dcc9e4 100644 --- a/.gitignore +++ b/.gitignore @@ -131,7 +131,6 @@ dbc_extract3/cache/ptr/DBCache.bin .direnv .envrc result -.pre-commit-config.yaml apikey.txt From 1b246b0b86a87cf55519d0224a54132229834389 Mon Sep 17 00:00:00 2001 From: Denis Craig Date: Thu, 26 Mar 2026 02:03:13 +0000 Subject: [PATCH 6/6] compute version from config.hpp in nix packages --- flake.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 063f3aa84a1..e7ba4190b1d 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,6 @@ flake-utils.lib.eachDefaultSystem ( system: let - rev = self.rev or "dirty"; pkgs = import nixpkgs { inherit system; }; llvm = pkgs.llvmPackages_latest; @@ -41,6 +40,13 @@ ]; qtNbi = with pkgs; [ qt6.wrapQtAppsHook ] ++ nbi; + + rev = self.rev or "dirty"; + version = pkgs.runCommand "version" { } '' + SC_MAJOR_VERSION=$(cat ${self}/engine/config.hpp | grep "#define SC_MAJOR_VERSION" | awk '{ print $3 }' | tr -d '"') + SC_MINOR_VERSION=$(cat ${self}/engine/config.hpp | grep "#define SC_MINOR_VERSION" | awk '{ print $3 }' | tr -d '"') + echo "$SC_MAJOR_VERSION"-"$SC_MINOR_VERSION" >> $out + ''; in { devShells = { @@ -60,7 +66,7 @@ default = self.packages.${system}.simc; simc = llvm.stdenv.mkDerivation { pname = "simc"; - version = "1201.01.${rev}"; + version = "${builtins.readFile version}${rev}"; src = self; nativeBuildInputs = nbi; buildInputs = packages; @@ -71,7 +77,7 @@ simcqt = llvm.stdenv.mkDerivation { pname = "simcqt"; - version = "1201.01.${rev}"; + version = "${builtins.readFile version}${rev}"; src = self; nativeBuildInputs = qtNbi; buildInputs = qtPackages;