diff --git a/flake.lock b/flake.lock index 660a40f..8ab3264 100644 --- a/flake.lock +++ b/flake.lock @@ -1,6 +1,75 @@ { "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" + } + }, + "flake-utils_3": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -17,11 +86,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1675918889, - "narHash": "sha256-hy7re4F9AEQqwZxubct7jBRos6md26bmxnCjxf5utJA=", + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "49efda9011e8cdcd6c1aad30384cb1dc230c82fe", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", "type": "github" }, "original": { @@ -48,11 +117,11 @@ }, "oxalica": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_3", "nixpkgs": "nixpkgs_2" }, "locked": { - "narHash": "sha256-0eO3S+2gLODqDoloufeC99PfQ5mthuN9JADzqFXid1Y=", + "narHash": "sha256-0E/zReDMCVEV24OCISKEw0ofPkW8ZSlLwD/XDwSOFFI=", "type": "tarball", "url": "https://github.com/oxalica/rust-overlay/archive/master.tar.gz" }, @@ -63,18 +132,45 @@ }, "root": { "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs", "oxalica": "oxalica", "unstable": "unstable" } }, + "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" + } + }, "unstable": { "locked": { - "lastModified": 1675942811, - "narHash": "sha256-/v4Z9mJmADTpXrdIlAjFa1e+gkpIIROR670UVDQFwIw=", + "lastModified": 1678898370, + "narHash": "sha256-xTICr1j+uat5hk9FyuPOFGxpWHdJRibwZC+ATi0RbtE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "724bfc0892363087709bd3a5a1666296759154b1", + "rev": "ac718d02867a84b42522a0ece52d841188208f2c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index edd8a3e..f14d1b8 100644 --- a/flake.nix +++ b/flake.nix @@ -2,22 +2,33 @@ description = "Lumenescent Dreams Tools"; inputs = { + crane.inputs.nixpkgs.follows = "nixpkgs"; + crane.url = "github:ipetkov/crane"; nixpkgs.url = "nixpkgs/nixos-22.11"; - unstable.url = "nixpkgs/nixos-unstable"; oxalica.url = "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"; + unstable.url = "nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, unstable, oxalica }: - let - version = builtins.string 0 8 self.lastModifiedDate; - supportedSystems = [ "x86_64-linux" ]; - in + outputs = inputs@{ self, nixpkgs, unstable, oxalica, crane, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + version = builtins.string 0 8 self.lastModifiedDate; + pkgs = import nixpkgs { inherit system; }; + craneLib = crane.lib.${system}; + projects = { + glimmer = import ./glimmer/rust { inherit inputs system; }; + }; + + in { - devShell."x86_64-linux" = + packages.glimmer = projects.glimmer.package; + + devShells.default = let rust_overlay = import oxalica; - pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ rust_overlay ]; }; - pkgs-unstable = import unstable { system = "x86_64-linux"; overlays = [ rust_overlay ]; }; + pkgs = import nixpkgs { inherit system; overlays = [ rust_overlay ]; }; + pkgs-unstable = import unstable { inherit system; overlays = [ rust_overlay ]; }; rust = pkgs.rust-bin.stable."1.65.0".default.override { extensions = [ "rust-src" ]; }; @@ -44,5 +55,7 @@ ]; LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"; }; - }; + + checks = projects.glimmer.checks; + }); } diff --git a/glimmer/rust/Cargo.lock b/glimmer/rust/Cargo.lock index 2297a1e..05050a2 100644 --- a/glimmer/rust/Cargo.lock +++ b/glimmer/rust/Cargo.lock @@ -272,6 +272,15 @@ dependencies = [ "system-deps", ] +[[package]] +name = "glimmer" +version = "0.1.0" +dependencies = [ + "glib", + "glib-build-tools", + "gtk4", +] + [[package]] name = "gobject-sys" version = "0.16.3" @@ -539,15 +548,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rust" -version = "0.1.0" -dependencies = [ - "glib", - "glib-build-tools", - "gtk4", -] - [[package]] name = "rustc_version" version = "0.4.0" diff --git a/glimmer/rust/Cargo.toml b/glimmer/rust/Cargo.toml index 6ba0b68..d95cfbf 100644 --- a/glimmer/rust/Cargo.toml +++ b/glimmer/rust/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rust" +name = "glimmer" version = "0.1.0" edition = "2021" diff --git a/glimmer/rust/default.nix b/glimmer/rust/default.nix new file mode 100644 index 0000000..0092ce1 --- /dev/null +++ b/glimmer/rust/default.nix @@ -0,0 +1,49 @@ +{ inputs, system }: +let + pkgs = import inputs.unstable { inherit system; }; + craneLib = inputs.crane.lib.${system}; + + src = ./.; + + cargoArtifacts = craneLib.buildDepsOnly { + name = "glimmer-deps"; + inherit src; + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.glib + pkgs.gtk4 + ]; + }; + + glimmer-clippy = craneLib.cargoClippy { + name = "glimmer-clippy"; + inherit cargoArtifacts src; + cargoClippyExtraArgs = "-- --deny warnings"; + }; + + glimmer = craneLib.vendorCargoDeps { + name = "glimmer"; + inherit cargoArtifacts src; + + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.glib + pkgs.gtk4 + ]; + }; +in +{ + package = glimmer; + /* + devShells.default = pkgs.mkShell { + inputsFrom = builtins.attrValues self.checks.${system}; + nativeBuildInputs = with pkgs; [ + cargo + rustc + ]; + }; + */ + checks = { + inherit glimmer glimmer-clippy; + }; +} diff --git a/glimmer/rust/flake.lock b/glimmer/rust/flake.lock deleted file mode 100644 index 66963fa..0000000 --- a/glimmer/rust/flake.lock +++ /dev/null @@ -1,123 +0,0 @@ -{ - "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 deleted file mode 100644 index 774e632..0000000 --- a/glimmer/rust/flake.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - crane.url = "github:ipetkov/crane"; - crane.inputs.nixpkgs.follows = "nixpkgs"; - flake-utils.url = "github:numtide/flake-utils"; - }; - - outputs = { self, nixpkgs, crane, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - craneLib = crane.lib.${system}; - - src = ./.; - - cargoArtifacts = craneLib.buildDepsOnly { - name = "glimmer-deps"; - inherit src; - nativeBuildInputs = [ - pkgs.pkg-config - pkgs.glib - pkgs.gtk4 - ]; - }; - - glimmer-clippy = craneLib.cargoClippy { - name = "glimmer-clippy"; - inherit cargoArtifacts src; - cargoClippyExtraArgs = "-- --deny warnings"; - }; - - glimmer = craneLib.buildPackage { - name = "glimmer"; - inherit cargoArtifacts src; - - nativeBuildInputs = [ - pkgs.pkg-config - pkgs.glib - pkgs.gtk4 - ]; - }; - in - { - packages.default = glimmer; - devShells.default = pkgs.mkShell { - inputsFrom = builtins.attrValues self.checks.${system}; - 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 905c872..a7a18a8 100644 --- a/glimmer/rust/src/lib.rs +++ b/glimmer/rust/src/lib.rs @@ -2,7 +2,7 @@ use glib::Object; use gtk::{prelude::*, subclass::prelude::*}; pub struct Card { - children: Vec, + pub children: Vec, } #[derive(Default)] @@ -31,9 +31,10 @@ impl CardElement { } } -struct TextField { - placeholder: String, - text: String, +#[derive(Clone, Debug)] +pub struct TextField { + pub placeholder: String, + pub text: String, } #[derive(Default)]