{ inputs = { # nixpkgs 35.11 still contains rust 1.73 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; crane = { url = "github:ipetkov/crane"; }; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; mize_modules = { url = "github:c2vi/mize-modules?submodules=1"; flake = false; }; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, flake-utils, nixpkgs, fenix, crane, mize_modules, rust-overlay, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: ############################## LET BINDINGS ############################## let pkgs = nixpkgs.legacyPackages.${system}; #os osToolchain = fenix.packages.${system}.latest.toolchain; osCrane = (crane.mkLib pkgs).overrideToolchain osToolchain; # mize build time config mizeBuildConfig = { config = { namespace = "mize.buildtime.ns"; module_url = "parts.mize.works"; }; }; in { ############################## PACKAGES ############################## packages = rec { fileSetForCrate = crate: pkgs.lib.fileset.toSource { root = ./.; fileset = pkgs.lib.fileset.unions [ ./Cargo.toml ./Cargo.lock (osCrane.fileset.commonCargoSources ./packages/marts) (osCrane.fileset.commonCargoSources ./packages/mize) (osCrane.fileset.commonCargoSources ./packages/ppc/spacetimedb) (osCrane.fileset.commonCargoSources ./packages/mme) (osCrane.fileset.commonCargoSources ./packages/vic) (osCrane.fileset.commonCargoSources ./packages/ac_mize_macros) (osCrane.fileset.commonCargoSources crate) ]; }; ppc = osCrane.buildPackage { src = fileSetForCrate ./packages/ppc; cargoExtraArgs = "-p ppc"; nativeBuildInputs = [ pkgs.pkg-config pkgs.gobject-introspection pkgs.gobject-introspection.dev ]; buildInputs = with pkgs; [ git # needed to build spacetimedb as it needs to get it's git hash for setting it's version at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 pango webkitgtk_4_1 openssl wasm-bindgen-cli lld_20 xdotool ]; LD_LIBRARY_PATH = with pkgs; pkgs.lib.makeLibraryPath [ xdotool webkitgtk_4_1 pango openssl at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 ]; }; mize = osCrane.buildPackage { src = fileSetForCrate ./packages/mize; cargoExtraArgs = "-p mize"; nativeBuildInputs = [ pkgs.pkg-config pkgs.gobject-introspection pkgs.gobject-introspection.dev ]; buildInputs = with pkgs; [ git # needed to build spacetimedb as it needs to get it's git hash for setting it's version at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 pango webkitgtk_4_1 openssl wasm-bindgen-cli lld_20 xdotool ]; LD_LIBRARY_PATH = with pkgs; pkgs.lib.makeLibraryPath [ xdotool webkitgtk_4_1 pango openssl at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 ]; }; }; ############################## DEV SHELLS ############################## devShells = { # shell without spacetime and other dev commands. just all needed to build mize or ppc buildShell = pkgs.mkShell { MIZE_BUILD_CONFIG = let settingsFormat = pkgs.formats.toml { }; in settingsFormat.generate "mize-build-config.toml" { config = mizeBuildConfig; }; shellHook = '' mize_project_root=$(${pkgs.lib.getExe pkgs.git} rev-parse --show-toplevel) export MIZE_CONFIG_FILES=$mize_project_root/mize_config.toml ''; nativeBuildInputs = [ pkgs.wasm-pack pkgs.pkg-config pkgs.gobject-introspection pkgs.gobject-introspection.dev # thanks to: https://github.com/NixOS/nixpkgs/pull/496279/changes (pkgs.buildWasmBindgenCli rec { src = pkgs.fetchCrate { pname = "wasm-bindgen-cli"; version = "0.2.114"; hash = "sha256-xrCym+rFY6EUQFWyWl6OPA+LtftpUAE5pIaElAIVqW0="; }; cargoDeps = pkgs.rustPlatform.fetchCargoVendor { inherit src; inherit (src) pname version; hash = "sha256-Z8+dUXPQq7S+Q7DWNr2Y9d8GMuEdSnq00quUR0wDNPM="; }; }) (fenix.packages.${system}.combine [ fenix.packages.${system}.latest.toolchain fenix.packages.${system}.targets.wasm32-unknown-unknown.latest.toolchain ]) ]; buildInputs = with pkgs; [ at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 pango webkitgtk_4_1 openssl wasm-bindgen-cli lld_20 xdotool ]; LD_LIBRARY_PATH = with pkgs; pkgs.lib.makeLibraryPath [ xdotool webkitgtk_4_1 pango openssl at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 ]; }; default = pkgs.mkShell { MIZE_BUILD_CONFIG = let settingsFormat = pkgs.formats.toml { }; in settingsFormat.generate "mize-build-config.toml" { config = mizeBuildConfig; }; shellHook = '' mize_project_root=$(${pkgs.lib.getExe pkgs.git} rev-parse --show-toplevel) ''; #_shell_type = "rust"; nativeBuildInputs = [ pkgs.wasm-pack pkgs.dioxus-cli pkgs.spacetimedb pkgs.deno pkgs.pkg-config pkgs.gobject-introspection pkgs.gobject-introspection.dev # thanks to: https://github.com/NixOS/nixpkgs/pull/496279/changes (pkgs.buildWasmBindgenCli rec { src = pkgs.fetchCrate { pname = "wasm-bindgen-cli"; version = "0.2.114"; hash = "sha256-xrCym+rFY6EUQFWyWl6OPA+LtftpUAE5pIaElAIVqW0="; }; cargoDeps = pkgs.rustPlatform.fetchCargoVendor { inherit src; inherit (src) pname version; hash = "sha256-Z8+dUXPQq7S+Q7DWNr2Y9d8GMuEdSnq00quUR0wDNPM="; }; }) (fenix.packages.${system}.combine [ fenix.packages.${system}.latest.toolchain fenix.packages.${system}.targets.wasm32-unknown-unknown.latest.toolchain ]) ]; buildInputs = with pkgs; [ at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 pango webkitgtk_4_1 openssl wasm-bindgen-cli lld_20 xdotool ]; LD_LIBRARY_PATH = with pkgs; pkgs.lib.makeLibraryPath [ xdotool webkitgtk_4_1 pango openssl at-spi2-atk atkmm cairo gdk-pixbuf glib gtk3 harfbuzz librsvg libsoup_3 ]; }; }; }) // rec { ############################## SOME GLOBAL OUTPUTS ############################## inherit inputs self; ############################## NIXOS MODULES ############################## nixosModules.default = { system, lib, config, pkgs, ... }: { options.mize = { enable = lib.mkEnableOption "enable the mize damon"; debugBinary = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; example = "/home/user/here/mize"; description = "If set to NOT null, the mize daemon service will use this path instead of $${self.packages.system.mize}/bin/mize''"; }; debugConfigFile = lib.mkOption { type = lib.types.nullOr lib.types.str; default = null; example = "/home/user/here/mize.toml"; description = "If set to NOT null, the mize daemon service will use the config file at this path instead of one written to the nix store"; }; enableConfigFile = lib.mkOption { type = lib.types.bool; default = true; description = "allows to disable setting MIZE_CONFIG_FILES env var for the mize daemon service"; }; config = lib.mkOption { type = lib.types.attrsOf lib.types.anything; default = {}; example = { dat_dir = "home/user/my_mize_data"; spacetime.url = "spacetime.example.com"; }; description = "mize config for the daemon"; }; }; config = lib.mkIf config.mize.enable { systemd.user.services.mize = { description = "the mize daemon"; wantedBy = [ "default.target" ]; environment = lib.mkIf config.mize.enableConfigFile { MIZE_CONFIG_FILES = let fileInStore = (pkgs.formats.toml {}).generate "mize-daemon-config.toml" config.mize.config; in if config.mize.debugConfigFile == null then "${fileInStore}" else "${config.mize.debugConfigFile}"; }; serviceConfig = { Restart = "on-failure"; ExecStart = if config.mize.debugBinary == null then "${self.packages.${system}.mize}/bin/mize daemon" else "${config.mize.debugBinary} daemon"; After = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ]; # this should mean DISPLAY and WAYLAND_DISPLAY are set in the service env... }; }; }; }; # for what we do the nixos and home-manager api is identical homeModules.default = nixosModules.default; }; }