Skip to content

Init nix flakes #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 152 commits into from
Jul 2, 2025
Merged

Init nix flakes #208

merged 152 commits into from
Jul 2, 2025

Conversation

haruki7049
Copy link
Contributor

@haruki7049 haruki7049 commented Nov 18, 2024

This PR creates /flake.nix and /flake.lock files.

Changes

  • Create /flake.nix and /flake.lock
    • This PR allow this following commands to be run:
nix build .#simula
nix build
  • nix profile command support
    • Then you can run nix profile install github:haruki7049/Simula/init-flakes -L
  • Delete /pinned-nixpkgs.nix
  • Delete externalSrc attribute and localSrc declaration. Use override function to override src attribute.
  • Delete unused submodule, godot_headers
  • Update wlroots and godot submodule
  • Initialize nix-direnv to use .#devShells.default
  • Initialize /.envrc to use nix-direnv
  • Add nix-checker CI to check Nix derivation
  • Add /addons/godot-haskell-plugin/justfile
    • Available recipes
      • build
      • default
      • profile-build
      • watch-build

My environment

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.62, NixOS, 25.05 (Warbler), 25.05beta710087.23e89b7da85c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.10`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

@haruki7049 haruki7049 marked this pull request as ready for review November 21, 2024 02:10
@haruki7049 haruki7049 marked this pull request as draft November 21, 2024 02:11
@haruki7049
Copy link
Contributor Author

I made a mistake. For now this PR should be draft

@haruki7049
Copy link
Contributor Author

Commit hash: 3c58c0c

I build Simula with below diff and nix-build -E 'with import <nixpkgs> { }; callPackage ./. { onNixOS = true; devBuild = true; }', then this build successed.

diff --git a/.gitmodules b/.gitmodules
index 2cb9882..271bbcd 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,8 +4,8 @@
        shallow = true
 [submodule "submodules/wlroots"]
        path = submodules/wlroots
-       url = https://github.com/SimulaVR/wlroots
-       branch = simula
+       url = https://github.com/haruki7049/wlroots-simula
+       branch = edit-nix-files
        shallow = true
 [submodule "submodules/godot"]
        path = submodules/godot
@@ -41,4 +41,4 @@
 [submodule "submodules/monado"]
        path = submodules/monado
        url = https://github.com/SimulaVR/monado-xv.git
-       branch = xr50
\ No newline at end of file
+       branch = xr50
diff --git a/Simula.nix b/Simula.nix
index 5166a0f..b62b1c0 100644
--- a/Simula.nix
+++ b/Simula.nix
@@ -23,7 +23,7 @@ let
     wayland-protocols-dev = wayland-protocols.overrideAttrs (oldAttrs: {
       stdenv = stdenvRes;
     });
-    wlroots-dev = callPackage ./submodules/wlroots/wlroots.nix { stdenv = stdenvRes; };
+    wlroots-dev = callPackage ./submodules/wlroots { stdenv = stdenvRes; };
     vulkan-loader-custom = if onNixOS then vulkan-loader else (callPackage ./nix/vulkan-loader.nix { });
     glibc-locales = glibcLocales;
     godot = callPackage ./submodules/godot/godot.nix { devBuild = devBuild; onNixOS = onNixOS; };
diff --git a/submodules/wlroots b/submodules/wlroots
index 017c7ca..7a3d488 160000
--- a/submodules/wlroots
+++ b/submodules/wlroots
@@ -1 +1 @@
-Subproject commit 017c7ca435e2198fab6fde16db918b64aa0d6232
+Subproject commit 7a3d48833ad58a19fed81f87744a0e69f505f3f5

@haruki7049
Copy link
Contributor Author

Commit hash: 3c58c0c

I build Simula with below diff and nix-build -E 'with import <nixpkgs> { }; callPackage ./. { onNixOS = true; devBuild = true; }', then this build successed.

This means that SimulaVR can be built with Nix flakes if SimulaVR/wlroots#1 merged into SimulaVR/wlroots

@haruki7049
Copy link
Contributor Author

haruki7049 commented Nov 21, 2024

Commit hash: b539685

I am so sad, because I understand that we cannot use Git submodules in checks attrset... We can still use Git submodules by nix build command, by:

nix build .?submodules=1#devBuild-onNixOS

@haruki7049
Copy link
Contributor Author

haruki7049 commented Nov 24, 2024

I can do these things but I cannot judge whether I should do in this PR or not:

  • As /.github/workflows/nix-checker, Create an Action to check whether Simula can be built with nix build command.
  • In the flakes, Create devShells.${system}.default for developing

I also can do these things but I don't think that I should do in this PR:

  • Move /Simula.nix to /default.nix in order to build with nix-build -E 'with import <nixpkgs> { }; callPackage ./. { }
  • Refactoring the Derivation in /Simula.nix, such as organize buildInputs and installPhase attributes

@haruki7049 haruki7049 marked this pull request as ready for review November 25, 2024 20:11
@haruki7049
Copy link
Contributor Author

haruki7049 commented Nov 26, 2024

TODO:

  • Delete Shell scripts
  • Delete devBuild
  • Delete onNixOS
  • Initialize /.github/workflows/nix-checker.yml
  • Refactoring Simula.nix and default.nix

@haruki7049 haruki7049 marked this pull request as draft November 26, 2024 05:31
@haruki7049
Copy link
Contributor Author

I'll do some more work...

haruki7049 and others added 26 commits April 22, 2025 09:55
- This avoids installation conflicts in case the user already has some of these programs installed.
- Removes SIMULA_APP_DIR support since we no longer use it.
  - Involves flake.nix + Haskell sources edits
- Add back simula-monado-service
These nix fields can lead to potential package collisions:

  - propagatedBuildInputs
  - propagatedUserEnvPkgs
  - propagatedNativeBuildInputs

`getPropagatedPackages()` takes Simula's ./flake.nix and returns a list of all propagated packages for inspection.
`getNixDependenciesWhichInvolve` shows you a tree of dependencies
of a flake (`$1`) which somehow involve the pattern `$2`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants