Skip to content
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

chore: Enforce nix formatting #15

Merged
merged 10 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 14 additions & 33 deletions .github/workflows/qc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ inputs:
runs:
using: "composite"
steps:
- name: Install Dependencies
- name: Install nix
uses: cachix/install-nix-action@v27

- name: Nix Formatting
shell: bash
run: |
set -ex
sudo apt-get update
sudo apt-get install --yes clang-format-13
pip install cmake_format==0.6.9 aqtinstall
nix develop --ignore-environment --command nixfmt --version
nix develop --ignore-environment --command find . -type f -regex '.*\.nix' -exec nixfmt {} +
git diff
git diff --quiet

- name: Check Conventional Commits
# Ensure that the PR title fits the conventional commits framework
Expand All @@ -28,49 +32,26 @@ runs:
shell: bash
run: |
set -ex
clang-format-13 --version
find src/ -type f -regex '.*\.\(c\|cpp\|h\|hpp\|hui\)' -exec clang-format-13 -i {} +
nix develop --ignore-environment --command clang-format --version
nix develop --ignore-environment --command find src/ -type f -regex '.*\.\(c\|cpp\|h\|hpp\|hui\)' -exec clang-format -i {} +
git diff
git diff --quiet

- name: CMake Formatting
shell: bash
run: |
set -ex
cmake-format --version
find src/ -type f -name CMakeLists.txt -exec cmake-format -i '{}' \;
nix develop --ignore-environment --command cmake-format --version
nix develop --ignore-environment --command find src/ -type f -name CMakeLists.txt -exec cmake-format -i '{}' \;
git diff
git diff --quiet

- name: Retrieve Qt Cache
id: cache-qt
uses: actions/cache@v4
with:
key: linux-qt-${{ inputs.qtVersion }}
path: ${{ runner.temp }}/qt

- name: Install Qt
if: ${{ steps.cache-qt.outputs.cache-hit != 'true' }}
shell: bash
run: |
export PATH="$(python3 -m site --user-base)/bin:$PATH"
aqt install-qt --outputdir ${{ runner.temp }}/qt linux desktop ${{ inputs.qtVersion }}

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ inputs.qtVersion }}
host: linux
target: desktop
dir: ${{ runner.temp }}/qt
cache: true

- name: QML Formatting
shell: bash
run: |
set -ex
${{ runner.temp }}/qt/${{ inputs.qtVersion }}/gcc_64/bin/qmlformat --version
find . -type f -regex '.*\.qml' -exec ${{ runner.temp }}/qt/${{ inputs.qtVersion }}/gcc_64/bin/qmlformat -inw 4 '{}' \;
nix develop --ignore-environment --command qmlformat --version
nix develop --ignore-environment --command find . -type f -regex '.*\.qml' -exec qmlformat -inw 4 '{}' \;
git diff
git diff --quiet

Expand Down
158 changes: 86 additions & 72 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
nixGL-src.url = "github:guibou/nixGL";
nixGL-src.flake = false;
};
outputs =
{ self, nixpkgs, future, flake-utils, bundlers, nixGL-src }:
outputs = { self, nixpkgs, future, flake-utils, bundlers, nixGL-src }:
let

version = "0.1";
Expand All @@ -27,80 +26,95 @@
];
check_libs = pkgs: with pkgs; [ gtest ];

in
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
in flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:

let
pkgs = import nixpkgs { inherit system; };
next = import future { inherit system; };
nixGL = import nixGL-src { inherit pkgs; };
qt = pkgs.qt6; # qt-idaaas.packages.${system};
in
{
devShells.default = pkgs.stdenv.mkDerivation {
name = "mildred-shell";
buildInputs = base_libs pkgs ++ gui_libs {inherit pkgs; q=qt;} ++ check_libs pkgs
++ (with pkgs; [
(pkgs.clang-tools.override {
llvmPackages = pkgs.llvmPackages_13;
})
ccache
ccls
cmake-format
cmake-language-server
distcc
gdb
next.git-cliff
valgrind
]);
shellHook = ''
export XDG_DATA_DIRS=$GSETTINGS_SCHEMAS_PATH:$XDG_DATA_DIRS
export LIBGL_DRIVERS_PATH=${pkgs.lib.makeSearchPathOutput "lib" "lib/dri" [pkgs.mesa.drivers]}
export LIBVA_DRIVERS_PATH=${pkgs.lib.makeSearchPathOutput "out" "lib/dri" [pkgs.mesa.drivers]}
export __EGL_VENDOR_LIBRARY_FILENAMES=${pkgs.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.mesa.drivers]}:${pkgs.lib.makeSearchPathOutput "lib" "lib/vdpau" [pkgs.libvdpau]}:${pkgs.lib.makeLibraryPath [pkgs.libglvnd]}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export QT_PLUGIN_PATH="${qt.qt3d}/lib/qt-6/plugins:${qt.qtsvg}/lib/qt-6/plugins:$QT_PLUGIN_PATH"
'';
QML_IMPORT_PATH = "${qt.qtdeclarative}/lib/qt-6/qml/:${qt.qt3d}/lib/qt-6/qml/:${qt.qtquick3d}/lib/qt-6/qml/";
};
let
pkgs = import nixpkgs { inherit system; };
next = import future { inherit system; };
nixGL = import nixGL-src { inherit pkgs; };
qt = pkgs.qt6; # qt-idaaas.packages.${system};
in {
devShells.default = pkgs.stdenv.mkDerivation {
name = "mildred-shell";
buildInputs = base_libs pkgs ++ gui_libs {
inherit pkgs;
q = qt;
} ++ check_libs pkgs ++ (with pkgs; [
(pkgs.clang-tools.override { llvmPackages = pkgs.llvmPackages_13; })
ccache
ccls
cmake-format
cmake-language-server
distcc
gdb
next.git-cliff
nixfmt
valgrind
]);
shellHook = ''
export XDG_DATA_DIRS=$GSETTINGS_SCHEMAS_PATH:$XDG_DATA_DIRS
export LIBGL_DRIVERS_PATH=${
pkgs.lib.makeSearchPathOutput "lib" "lib/dri"
[ pkgs.mesa.drivers ]
}
export LIBVA_DRIVERS_PATH=${
pkgs.lib.makeSearchPathOutput "out" "lib/dri"
[ pkgs.mesa.drivers ]
}
export __EGL_VENDOR_LIBRARY_FILENAMES=${pkgs.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json
export LD_LIBRARY_PATH=${
pkgs.lib.makeLibraryPath [ pkgs.mesa.drivers ]
}:${
pkgs.lib.makeSearchPathOutput "lib" "lib/vdpau" [ pkgs.libvdpau ]
}:${
pkgs.lib.makeLibraryPath [ pkgs.libglvnd ]
}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export QT_PLUGIN_PATH="${qt.qt3d}/lib/qt-6/plugins:${qt.qtsvg}/lib/qt-6/plugins:$QT_PLUGIN_PATH"
'';
QML_IMPORT_PATH =
"${qt.qtdeclarative}/lib/qt-6/qml/:${qt.qt3d}/lib/qt-6/qml/:${qt.qtquick3d}/lib/qt-6/qml/";
};

apps = {
default =
flake-utils.lib.mkApp { drv = self.packages.${system}.library; };
};
apps = {
default =
flake-utils.lib.mkApp { drv = self.packages.${system}.library; };
};

packages = {
library = pkgs.stdenv.mkDerivation ({
inherit version;
pname = "mildred";
src = ./.;
buildInputs = base_libs pkgs ++ (gui_libs {inherit pkgs; q=qt;});
nativeBuildInputs = [ pkgs.wrapGAppsHook ];
packages = {
library = pkgs.stdenv.mkDerivation ({
inherit version;
pname = "mildred";
src = ./.;
buildInputs = base_libs pkgs ++ (gui_libs {
inherit pkgs;
q = qt;
});
nativeBuildInputs = [ pkgs.wrapGAppsHook ];

cmakeFlags = [ "-G Ninja -DBUILD_EXAMPLES:bool=true"];
installPhase = ''
mkdir -p $out/bin
mv ./$out/bin/groups $out/bin/
'';
cmakeFlags = [ "-G Ninja -DBUILD_EXAMPLES:bool=true" ];
installPhase = ''
mkdir -p $out/bin
mv ./$out/bin/groups $out/bin/
'';

meta = with pkgs.lib; {
description = "Plot lib for 2D/3D";
homepage = "https://github.com/disorderedmaterials/plot";
license = licenses.gpl3;
maintainers = with maintainers; [ rprospero ];
};
});
meta = with pkgs.lib; {
description = "Plot lib for 2D/3D";
homepage = "https://github.com/disorderedmaterials/plot";
license = licenses.gpl3;
maintainers = with maintainers; [ rprospero ];
};
});

singularity =
nixpkgs.legacyPackages.${system}.singularity-tools.buildImage {
name = "mildred-${version}";
diskSize = 1024 * 250;
memSize = 1024 * 2;
contents = [
self.packages.${system}.library
];
runScript = "${nixGL.nixGLIntel}/bin/nixGLIntel ${self.packages.${system}.library}/bin/groups $@";
};
};
});
singularity =
nixpkgs.legacyPackages.${system}.singularity-tools.buildImage {
name = "mildred-${version}";
diskSize = 1024 * 250;
memSize = 1024 * 2;
contents = [ self.packages.${system}.library ];
runScript = "${nixGL.nixGLIntel}/bin/nixGLIntel ${
self.packages.${system}.library
}/bin/groups $@";
};
};
});
}
Loading