diff --git a/.gitignore b/.gitignore index cb37196ca9..16ed2f5a3b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,10 @@ noctalia # OS .DS_Store Thumbs.db + +# Nix +.envrc +.direnv/ +result/ +result +result-* \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..bc69ffd0fc --- /dev/null +++ b/flake.lock @@ -0,0 +1,24 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1777268161, + "narHash": "sha256-e1tDUQMbFCxCnke314UpghgRqg3FJLtcXFfq/WTRLYI=", + "rev": "1c3fe55ad329cbcb28471bb30f05c9827f724c76", + "type": "tarball", + "url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre987561.1c3fe55ad329/nixexprs.tar.xz" + }, + "original": { + "type": "tarball", + "url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..716dd16465 --- /dev/null +++ b/flake.nix @@ -0,0 +1,69 @@ +{ + description = "Noctalia - A lightweight Wayland shell and bar"; + + inputs = { + nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; + }; + + outputs = + { self, nixpkgs }: + let + inherit (nixpkgs) lib; + + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + + forEachSystem = + perSystem: + lib.genAttrs systems ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + perSystem { inherit pkgs system; } + ); + + mkDate = + longDate: + nixpkgs.lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]; + + version = mkDate (self.lastModifiedDate or "19700101") + "" + (self.shortRev or "dirty"); + in + { + overlays.default = final: prev: { + noctalia = final.callPackage ./nix/package.nix { inherit version; }; + }; + + packages = forEachSystem ( + { pkgs, ... }: + { + default = pkgs.callPackage ./nix/package.nix { inherit version; }; + } + ); + + devShells = forEachSystem ( + { pkgs, system }: + { + default = pkgs.callPackage ./nix/devshell.nix { + noctalia = self.packages.${system}.default; + }; + } + ); + + apps = forEachSystem ( + { system, ... }: + { + default = { + type = "app"; + program = lib.getExe self.packages.${system}.default; + }; + } + ); + }; +} diff --git a/nix/devshell.nix b/nix/devshell.nix new file mode 100644 index 0000000000..bcedb23c47 --- /dev/null +++ b/nix/devshell.nix @@ -0,0 +1,29 @@ +{ + pkgs, + noctalia, +}: +pkgs.mkShell { + inputsFrom = [ noctalia ]; + + nativeBuildInputs = with pkgs; [ + # Workflow & Hooks + just + lefthook + + # Formatting (required by justfile) + clang-tools + gnugrep + gnused + findutils + + # Debugging + gdb + ]; + + shellHook = '' + # Point to local assets so binaries find resources without installation + export NOCTALIA_ASSETS_DIR="$PWD/assets" + + echo " Noctalia dev-shell | 'just --list' to see available tasks" + ''; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000000..de8a4597e5 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,77 @@ +{ + lib, + stdenv, + version, + meson, + ninja, + pkg-config, + wayland-scanner, + wayland, + wayland-protocols, + libGL, + libglvnd, + freetype, + fontconfig, + cairo, + pango, + libxkbcommon, + sdbus-cpp_2, + systemd, + pipewire, + pam, + curl, + libwebp, + glib, + polkit +}: + +stdenv.mkDerivation { + pname = "noctalia"; + inherit version; + + src = lib.cleanSource ../.; + + postPatch = '' + # Remove -march=native and -mtune=native for reproducible builds + sed -i "s/'-march=native', '-mtune=native',//" meson.build + ''; + + nativeBuildInputs = [ + meson + ninja + pkg-config + wayland-scanner + ]; + + buildInputs = [ + wayland + wayland-protocols + libGL + libglvnd + freetype + fontconfig + cairo + pango + libxkbcommon + sdbus-cpp_2 + systemd + pipewire + pam + curl + libwebp + glib + polkit + ]; + + mesonBuildType = "release"; + + ninjaFlags = [ "-v" ]; + + meta = with lib; { + description = "A lightweight Wayland shell and bar built directly on Wayland + OpenGL ES"; + homepage = "https://github.com/noctalia-dev/noctalia-shell"; + license = licenses.mit; + platforms = platforms.linux; + mainProgram = "noctalia"; + }; +}