diff --git a/flake.nix b/flake.nix index 6889b48..edd8a3e 100644 --- a/flake.nix +++ b/flake.nix @@ -27,7 +27,6 @@ buildInputs = [ pkgs.clang pkgs.entr - pkgs.glade pkgs.glib pkgs.gst_all_1.gst-plugins-bad pkgs.gst_all_1.gst-plugins-base diff --git a/glimmer/rust/flake.lock b/glimmer/rust/flake.lock new file mode 100644 index 0000000..66963fa --- /dev/null +++ b/glimmer/rust/flake.lock @@ -0,0 +1,123 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1678152261, + "narHash": "sha256-cPRDxwygVMleiSEGELrvAiq9vYAN4c3KK/K4UEO13vU=", + "owner": "ipetkov", + "repo": "crane", + "rev": "5291dd0aa7a52d607fc952763ef60714e4c881d4", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678875422, + "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677812689, + "narHash": "sha256-EakqhgRnjVeYJv5+BJx/NZ7/eFTMBxc4AhICUNquhUg=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "e53e8853aa7b0688bc270e9e6a681d22e01cf299", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/glimmer/rust/flake.nix b/glimmer/rust/flake.nix index 2c865fe..774e632 100644 --- a/glimmer/rust/flake.nix +++ b/glimmer/rust/flake.nix @@ -1,122 +1,57 @@ { - description = "Build a cargo project"; - inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - crane = { - url = "github:ipetkov/crane"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - + crane.url = "github:ipetkov/crane"; + crane.inputs.nixpkgs.follows = "nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; - - advisory-db = { - url = "github:rustsec/advisory-db"; - flake = false; - }; }; - outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }: + outputs = { self, nixpkgs, crane, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - }; - - inherit (pkgs) lib; - + pkgs = import nixpkgs { inherit system; }; craneLib = crane.lib.${system}; - src = craneLib.cleanCargoSource ./.; - # Common arguments can be set here to avoid repeating them later - commonArgs = { + src = ./.; + + cargoArtifacts = craneLib.buildDepsOnly { + name = "glimmer-deps"; inherit src; - - buildInputs = [ - # Add additional build inputs here - ] ++ lib.optionals pkgs.stdenv.isDarwin [ - # Additional darwin specific inputs can be set here - pkgs.libiconv + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.glib + pkgs.gtk4 ]; - - # Additional environment variables can be set directly - # MY_CUSTOM_VAR = "some value"; }; - # Build *just* the cargo dependencies, so we can reuse - # all of that work (e.g. via cachix) when running in CI - cargoArtifacts = craneLib.buildDepsOnly commonArgs; + glimmer-clippy = craneLib.cargoClippy { + name = "glimmer-clippy"; + inherit cargoArtifacts src; + cargoClippyExtraArgs = "-- --deny warnings"; + }; - # Build the actual crate itself, reusing the dependency - # artifacts from above. - my-crate = craneLib.buildPackage (commonArgs // { - inherit cargoArtifacts; - }); + glimmer = craneLib.buildPackage { + name = "glimmer"; + inherit cargoArtifacts src; + + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.glib + pkgs.gtk4 + ]; + }; in { - checks = { - # Build the crate as part of `nix flake check` for convenience - inherit my-crate; - - # Run clippy (and deny all warnings) on the crate source, - # again, resuing the dependency artifacts from above. - # - # Note that this is done as a separate derivation so that - # we can block the CI if there are issues here, but not - # prevent downstream consumers from building our crate by itself. - my-crate-clippy = craneLib.cargoClippy (commonArgs // { - inherit cargoArtifacts; - cargoClippyExtraArgs = "--all-targets -- --deny warnings"; - }); - - my-crate-doc = craneLib.cargoDoc (commonArgs // { - inherit cargoArtifacts; - }); - - # Check formatting - my-crate-fmt = craneLib.cargoFmt { - inherit src; - }; - - # Audit dependencies - my-crate-audit = craneLib.cargoAudit { - inherit src advisory-db; - }; - - # Run tests with cargo-nextest - # Consider setting `doCheck = false` on `my-crate` if you do not want - # the tests to run twice - my-crate-nextest = craneLib.cargoNextest (commonArgs // { - inherit cargoArtifacts; - partitions = 1; - partitionType = "count"; - }); - } // lib.optionalAttrs (system == "x86_64-linux") { - # NB: cargo-tarpaulin only supports x86_64 systems - # Check code coverage (note: this will not upload coverage anywhere) - my-crate-coverage = craneLib.cargoTarpaulin (commonArgs // { - inherit cargoArtifacts; - }); - }; - - packages.default = my-crate; - - apps.default = flake-utils.lib.mkApp { - drv = my-crate; - }; - + packages.default = glimmer; devShells.default = pkgs.mkShell { inputsFrom = builtins.attrValues self.checks.${system}; - - # Additional dev-shell environment variables can be set directly - # MY_CUSTOM_DEVELOPMENT_VAR = "something else"; - - # Extra inputs can be added here nativeBuildInputs = with pkgs; [ cargo rustc ]; }; + checks = { + inherit glimmer glimmer-clippy; + }; }); } diff --git a/glimmer/rust/src/lib.rs b/glimmer/rust/src/lib.rs index 9af6f93..905c872 100644 --- a/glimmer/rust/src/lib.rs +++ b/glimmer/rust/src/lib.rs @@ -53,3 +53,11 @@ impl BoxImpl for TextFieldElementPrivate {} glib::wrapper! { pub struct TextFieldElement(ObjectSubclass) @extends gtk::Widget, gtk::Box; } + +#[cfg(test)] +mod test { + #[test] + fn it_succeeds() { + assert!(true); + } +}