mirror of
https://github.com/ryantm/nixpkgs-update.git
synced 2024-12-12 00:35:10 +03:00
start rust project
This commit is contained in:
parent
b297f32504
commit
b43e41fc14
1
rust/.direnv/flake-profile
Symbolic link
1
rust/.direnv/flake-profile
Symbolic link
@ -0,0 +1 @@
|
||||
flake-profile-1-link
|
1
rust/.direnv/flake-profile-1-link
Symbolic link
1
rust/.direnv/flake-profile-1-link
Symbolic link
@ -0,0 +1 @@
|
||||
/nix/store/v3k7n7q44754h7cd8fvr3gyjq6dwmqk8-nix-shell-env
|
2
rust/.envrc
Normal file
2
rust/.envrc
Normal file
@ -0,0 +1,2 @@
|
||||
use flake
|
||||
dotenv
|
2
rust/.gitignore
vendored
Normal file
2
rust/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
target
|
||||
db.sqlite
|
145
rust/Cargo.lock
generated
Normal file
145
rust/Cargo.lock
generated
Normal file
@ -0,0 +1,145 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929"
|
||||
|
||||
[[package]]
|
||||
name = "diesel"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7a532c1f99a0f596f6960a60d1e119e91582b24b39e2d83a190e61262c3ef0c"
|
||||
dependencies = [
|
||||
"diesel_derives",
|
||||
"libsqlite3-sys",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "diesel_derives"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74398b79d81e52e130d991afeed9c86034bb1b7735f46d2f5bf7deb261d80303"
|
||||
dependencies = [
|
||||
"diesel_table_macro_syntax",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "diesel_table_macro_syntax"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5"
|
||||
dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326"
|
||||
dependencies = [
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nixpkgs-update"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"diesel",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.183"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd"
|
||||
dependencies = [
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
9
rust/Cargo.toml
Normal file
9
rust/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "nixpkgs-update"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
diesel = { version = "2.1.0", features = ["sqlite"] }
|
9
rust/diesel.toml
Normal file
9
rust/diesel.toml
Normal file
@ -0,0 +1,9 @@
|
||||
# For documentation on how to configure this file,
|
||||
# see https://diesel.rs/guides/configuring-diesel-cli
|
||||
|
||||
[print_schema]
|
||||
file = "src/schema.rs"
|
||||
custom_type_derives = ["diesel::query_builder::QueryId"]
|
||||
|
||||
[migrations_directory]
|
||||
dir = "migrations"
|
25
rust/flake.lock
Normal file
25
rust/flake.lock
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1691709280,
|
||||
"narHash": "sha256-zmfH2OlZEXwv572d0g8f6M5Ac6RiO8TxymOpY3uuqrM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "cf73a86c35a84de0e2f3ba494327cf6fb51c0dfd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
16
rust/flake.nix
Normal file
16
rust/flake.nix
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
description = "update nixpkgs automatically";
|
||||
|
||||
outputs = { self, nixpkgs } @ args: let
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
in {
|
||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.cargo
|
||||
pkgs.clippy
|
||||
pkgs.sqlite
|
||||
pkgs.diesel-cli
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
@ -0,0 +1 @@
|
||||
DROP table packages;
|
27
rust/migrations/2023-08-12-152848_create_packages/up.sql
Normal file
27
rust/migrations/2023-08-12-152848_create_packages/up.sql
Normal file
@ -0,0 +1,27 @@
|
||||
CREATE TABLE packages (
|
||||
id text PRIMARY KEY NOT NULL
|
||||
, attr_path text NOT NULL
|
||||
, version_nixpkgs_master text
|
||||
, version_nixpkgs_staging text
|
||||
, version_nixpkgs_staging_next text
|
||||
, version_repology text
|
||||
, version_github text
|
||||
, version_gitlab text
|
||||
, version_pypi text
|
||||
, project_repology text
|
||||
, nixpkgs_name_replogy text
|
||||
, owner_github text
|
||||
, repo_github text
|
||||
, owner_gitlab text
|
||||
, repo_gitlab text
|
||||
, last_checked_repology text
|
||||
, last_checked_github text
|
||||
, last_hecked_gitlab text
|
||||
, last_hecked_pypi text
|
||||
, last_checked_pending_pr text
|
||||
, last_update_attempt text
|
||||
, pending_pr integer
|
||||
, pending_pr_owner text
|
||||
, pending_pr_branch_name text
|
||||
, last_update_log text
|
||||
)
|
11
rust/src/lib.rs
Normal file
11
rust/src/lib.rs
Normal file
@ -0,0 +1,11 @@
|
||||
pub mod models;
|
||||
pub mod schema;
|
||||
|
||||
use diesel::prelude::*;
|
||||
use std::env;
|
||||
|
||||
pub fn establish_connection() -> SqliteConnection {
|
||||
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
SqliteConnection::establish(&database_url)
|
||||
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
|
||||
}
|
18
rust/src/main.rs
Normal file
18
rust/src/main.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use nixpkgs_update::models::*;
|
||||
use nixpkgs_update::*;
|
||||
use diesel::prelude::*;
|
||||
|
||||
fn main() {
|
||||
use nixpkgs_update::schema::packages::dsl::*;
|
||||
|
||||
let connection = &mut establish_connection();
|
||||
let results : Vec<Package> =
|
||||
packages.
|
||||
load(connection)
|
||||
.expect("Error loading packages");
|
||||
|
||||
println!("Displaying {} packages", results.len());
|
||||
for package in results {
|
||||
println!("{} {}", package.id, package.attr_path);
|
||||
}
|
||||
}
|
33
rust/src/models.rs
Normal file
33
rust/src/models.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use diesel::prelude::*;
|
||||
|
||||
#[derive(Queryable, Selectable)]
|
||||
#[diesel(table_name = crate::schema::packages)]
|
||||
#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
|
||||
pub struct Package {
|
||||
pub id: String,
|
||||
pub attr_path: String,
|
||||
pub version_nixpkgs_master: Option<String>,
|
||||
pub version_nixpkgs_staging: Option<String>,
|
||||
pub version_nixpkgs_staging_next: Option<String>,
|
||||
pub version_repology: Option<String>,
|
||||
pub version_github: Option<String>,
|
||||
pub version_gitlab: Option<String>,
|
||||
pub version_pypi: Option<String>,
|
||||
pub project_repology: Option<String>,
|
||||
pub nixpkgs_name_replogy: Option<String>,
|
||||
pub owner_github: Option<String>,
|
||||
pub repo_github: Option<String>,
|
||||
pub owner_gitlab: Option<String>,
|
||||
pub repo_gitlab: Option<String>,
|
||||
pub last_checked_repology: Option<String>,
|
||||
pub last_checked_github: Option<String>,
|
||||
pub last_hecked_gitlab: Option<String>,
|
||||
pub last_hecked_pypi: Option<String>,
|
||||
pub last_checked_pending_pr: Option<String>,
|
||||
pub last_update_attempt: Option<String>,
|
||||
pub pending_pr: Option<i32>,
|
||||
pub pending_pr_owner: Option<String>,
|
||||
pub pending_pr_branch_name: Option<String>,
|
||||
pub last_update_log: Option<String>,
|
||||
|
||||
}
|
31
rust/src/schema.rs
Normal file
31
rust/src/schema.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// @generated automatically by Diesel CLI.
|
||||
|
||||
diesel::table! {
|
||||
packages (id) {
|
||||
id -> Text,
|
||||
attr_path -> Text,
|
||||
version_nixpkgs_master -> Nullable<Text>,
|
||||
version_nixpkgs_staging -> Nullable<Text>,
|
||||
version_nixpkgs_staging_next -> Nullable<Text>,
|
||||
version_repology -> Nullable<Text>,
|
||||
version_github -> Nullable<Text>,
|
||||
version_gitlab -> Nullable<Text>,
|
||||
version_pypi -> Nullable<Text>,
|
||||
project_repology -> Nullable<Text>,
|
||||
nixpkgs_name_replogy -> Nullable<Text>,
|
||||
owner_github -> Nullable<Text>,
|
||||
repo_github -> Nullable<Text>,
|
||||
owner_gitlab -> Nullable<Text>,
|
||||
repo_gitlab -> Nullable<Text>,
|
||||
last_checked_repology -> Nullable<Text>,
|
||||
last_checked_github -> Nullable<Text>,
|
||||
last_hecked_gitlab -> Nullable<Text>,
|
||||
last_hecked_pypi -> Nullable<Text>,
|
||||
last_checked_pending_pr -> Nullable<Text>,
|
||||
last_update_attempt -> Nullable<Text>,
|
||||
pending_pr -> Nullable<Integer>,
|
||||
pending_pr_owner -> Nullable<Text>,
|
||||
pending_pr_branch_name -> Nullable<Text>,
|
||||
last_update_log -> Nullable<Text>,
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user