diff --git a/README.md b/README.md index e17274a..adb56a2 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ application. To add your own flakes to the search index edit [./flakes/manual.toml](./flakes/manual.toml). -Possible types are `github`, `gitlab`, and `git` (which is the fallback for any kind of git repository but requires to set a revision key manually as of now). +Possible types are `github`, `gitlab`, `sourcehut`, and `git` (which is the fallback for any kind of git repository but requires to set a revision key manually as of now). To test whether your flake is compatible with nix flake-info you can try running `flake-info` against it diff --git a/flake-info/README.md b/flake-info/README.md index fd87f32..47de527 100644 --- a/flake-info/README.md +++ b/flake-info/README.md @@ -68,7 +68,8 @@ The `` argument should contain a valid reference to a flake. It accepts a > use git+ to checkout a git repository at > use /local/absolute/path or ./relative/path to load a local source -> use gitlab://github:/ to shortcut gitlab or github repositories +> use gitlab://github://sourcehut:/ to +> shortcut gitlab, github or sourcehut repositories Optionally, analyzing can be done in a temporary store enabled by the `--temp-store` option. @@ -97,7 +98,7 @@ $ flake-info nixpkgs nixos-21.05 to perform a bulk import grouping multiple inputs under the same name/index use the group command. -It expects a json file as input that contains references to flakes or nixpkgs. If those resources are on github or gitlab they can be extended with more meta information including pinning the commit hash/ref. +It expects a JSON file as input that contains references to flakes or nixpkgs. If those resources are on GitHub, GitLab or SourceHut they can be extended with more meta information including pinning the commit hash/ref. The second argument is the group name that is used to provide the index name. diff --git a/flake-info/src/data/flake.rs b/flake-info/src/data/flake.rs index 721f9a7..90cf052 100644 --- a/flake-info/src/data/flake.rs +++ b/flake-info/src/data/flake.rs @@ -33,19 +33,21 @@ impl Flake { Repo::Git { .. } => Default::default(), Repo::GitHub { repo, .. } => repo.clone(), Repo::Gitlab { repo, .. } => repo.clone(), + Repo::SourceHut { repo, .. } => repo.clone(), }; self } } /// Information about the flake origin -/// Supports (local/raw) Git, GitHub and Gitlab repos +/// Supports (local/raw) Git, GitHub, SourceHut and Gitlab repos #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "lowercase")] pub enum Repo { Git { url: PathBuf }, GitHub { owner: String, repo: String }, Gitlab { owner: String, repo: String }, + SourceHut { owner: String, repo: String }, } #[cfg(test)] diff --git a/flake-info/src/data/source.rs b/flake-info/src/data/source.rs index 3159c99..96320b4 100644 --- a/flake-info/src/data/source.rs +++ b/flake-info/src/data/source.rs @@ -11,7 +11,7 @@ pub type Hash = String; pub type FlakeRef = String; /// Information about the flake origin -/// Supports (local/raw) Git, GitHub and Gitlab repos +/// Supports (local/raw) Git, GitHub, SourceHut and Gitlab repos #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "lowercase")] pub enum Source { @@ -27,6 +27,11 @@ pub enum Source { repo: String, git_ref: Option, }, + SourceHut { + owner: String, + repo: String, + git_ref: Option, + }, Git { url: String, }, @@ -66,6 +71,18 @@ impl Source { .as_ref() .map_or("".to_string(), |f| format!("?ref={}", f)) ), + Source::SourceHut { + owner, + repo, + git_ref, + } => format!( + "sourcehut:{}/{}{}", + owner, + repo, + git_ref + .as_ref() + .map_or("".to_string(), |f| format!("?ref={}", f)) + ), Source::Git { url } => url.to_string(), Source::Nixpkgs(Nixpkgs { git_ref, .. }) => format!( "https://api.github.com/repos/NixOS/nixpkgs/tarball/{}", diff --git a/frontend/src/Page/Packages.elm b/frontend/src/Page/Packages.elm index f94c8f6..f8d9c7c 100644 --- a/frontend/src/Page/Packages.elm +++ b/frontend/src/Page/Packages.elm @@ -1001,6 +1001,9 @@ decodeResolvedFlake = "gitlab" -> Maybe.map (\repoPath_ -> ( "gitlab:" ++ repoPath_, "https://gitlab.com/" ++ repoPath_ )) repoPath + "sourcehut" -> + Maybe.map (\repoPath_ -> ( "sourcehut:" ++ repoPath_, "https://sr.ht/" ++ repoPath_ )) repoPath + "git" -> Maybe.map (\url_ -> ( url_, url_ )) url diff --git a/frontend/src/Search.elm b/frontend/src/Search.elm index 6fe3320..b64b445 100644 --- a/frontend/src/Search.elm +++ b/frontend/src/Search.elm @@ -270,6 +270,9 @@ decodeResolvedFlake = "gitlab" -> Maybe.map (\repoPath_ -> "https://gitlab.com/" ++ repoPath_) repoPath + "sourcehut" -> + Maybe.map (\repoPath_ -> "https://sr.ht/" ++ repoPath_) repoPath + "git" -> url