Skip to content

Commit

Permalink
style: format ff4ea84
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoudham authored May 21, 2024
1 parent ff4ea84 commit 5e1a679
Show file tree
Hide file tree
Showing 53 changed files with 587 additions and 635 deletions.
4 changes: 1 addition & 3 deletions .github/checkSources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ let
# find the ones that aren't
badSources = builtins.filter (source: !(isGoodSource source)) (builtins.attrValues sources);
in
if ((builtins.length badSources) == 0)
then "OK"
else throw "BAD"
if ((builtins.length badSources) == 0) then "OK" else throw "BAD"
48 changes: 33 additions & 15 deletions .sources/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,32 @@ let
data = builtins.fromJSON (builtins.readFile ./sources.json);
version = data.version;

mkSource = spec:
assert spec ? type; let
mkSource =
spec:
assert spec ? type;
let
path =
if spec.type == "Git" then mkGitSource spec
else if spec.type == "GitRelease" then mkGitSource spec
else if spec.type == "PyPi" then mkPyPiSource spec
else if spec.type == "Channel" then mkChannelSource spec
else builtins.throw "Unknown source type ${spec.type}";
if spec.type == "Git" then
mkGitSource spec
else if spec.type == "GitRelease" then
mkGitSource spec
else if spec.type == "PyPi" then
mkPyPiSource spec
else if spec.type == "Channel" then
mkChannelSource spec
else
builtins.throw "Unknown source type ${spec.type}";
in
spec // { outPath = path; };

mkGitSource = { repository, revision, url ? null, hash, ... }:
mkGitSource =
{
repository,
revision,
url ? null,
hash,
...
}:
assert repository ? type;
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
# In the latter case, there we will always be an url to the tarball
Expand All @@ -23,19 +37,23 @@ let
inherit url;
sha256 = hash; # FIXME: check nix version & use SRI hashes
})
else assert repository.type == "Git"; builtins.fetchGit {
url = repository.url;
rev = revision;
# hash = hash;
};
else
assert repository.type == "Git";
builtins.fetchGit {
url = repository.url;
rev = revision;
# hash = hash;
};

mkPyPiSource = { url, hash, ... }:
mkPyPiSource =
{ url, hash, ... }:
builtins.fetchurl {
inherit url;
sha256 = hash;
};

mkChannelSource = { url, hash, ... }:
mkChannelSource =
{ url, hash, ... }:
builtins.fetchTarball {
inherit url;
sha256 = hash;
Expand Down
91 changes: 61 additions & 30 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
};
};

outputs = { self, nixpkgs, nixpkgs-stable, home-manager, home-manager-stable }:
outputs =
{
self,
nixpkgs,
nixpkgs-stable,
home-manager,
home-manager-stable,
}:
let
systems = [
"x86_64-linux"
Expand All @@ -33,39 +40,62 @@
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgsFor.${system}.unstable);
in
{
apps = forAllSystems ({ lib, pkgs, system, ... }: {
add-source = {
type = "app";
program = lib.getExe (
pkgs.runCommand "add-source"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
meta.mainProgram = "add-source";
} ''
mkdir -p $out/bin
install -Dm755 ${./add_source.sh} $out/bin/add-source
wrapProgram $out/bin/add-source \
--prefix PATH : ${ lib.makeBinPath [ pkgs.npins ]}
''
);
};
apps = forAllSystems (
{
lib,
pkgs,
system,
...
}:
{
add-source = {
type = "app";
program = lib.getExe (
pkgs.runCommand "add-source"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
meta.mainProgram = "add-source";
}
''
mkdir -p $out/bin
install -Dm755 ${./add_source.sh} $out/bin/add-source
wrapProgram $out/bin/add-source \
--prefix PATH : ${lib.makeBinPath [ pkgs.npins ]}
''
);
};

serve = {
type = "app";
program = lib.getExe self.packages.${system}.site.serve;
};
});
serve = {
type = "app";
program = lib.getExe self.packages.${system}.site.serve;
};
}
);

checks = forAllSystems ({ lib, pkgs, system, ... }: lib.optionalAttrs pkgs.stdenv.isLinux {
module-test-unstable = pkgs.callPackage ../test.nix { inherit home-manager; };
module-test-stable = nixpkgsFor.${system}.stable.callPackage ../test.nix {
home-manager = home-manager-stable;
};
});
checks = forAllSystems (
{
lib,
pkgs,
system,
...
}:
lib.optionalAttrs pkgs.stdenv.isLinux {
module-test-unstable = pkgs.callPackage ../test.nix { inherit home-manager; };
module-test-stable = nixpkgsFor.${system}.stable.callPackage ../test.nix {
home-manager = home-manager-stable;
};
}
);

formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);

packages = forAllSystems ({ lib, pkgs, system, ... }:
packages = forAllSystems (
{
lib,
pkgs,
system,
...
}:
let
version = self.shortRev or self.dirtyShortRev or "unknown";
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
Expand Down Expand Up @@ -101,6 +131,7 @@
};

default = packages'.site;
});
}
);
};
}
95 changes: 48 additions & 47 deletions docs/mk-site.nix
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
{ lib
, stdenvNoCC
, writeShellApplication
, mdbook
, python3
}: { nixosDoc
, homeManagerDoc
, ...
}@args:
stdenvNoCC.mkDerivation (finalAttrs: args // {
nativeBuildInputs = [
mdbook
];

dontPatch = true;
dontConfigure = true;
doCheck = false;

buildPhase = ''
runHook preBuild
ln -s ${nixosDoc} src/options/nixos-options.md
ln -s ${homeManagerDoc} src/options/home-manager-options.md
mdbook build
runHook postBuild
'';

installPhase = ''
runHook preInstall
mv book $out
runHook postInstall
'';

passthru = {
serve = writeShellApplication {
name = "serve";

runtimeInputs = [ python3 ];

text = ''
python -m http.server --bind 127.0.0.1 --directory ${finalAttrs.finalPackage}
'';
{
lib,
stdenvNoCC,
writeShellApplication,
mdbook,
python3,
}:
{ nixosDoc, homeManagerDoc, ... }@args:
stdenvNoCC.mkDerivation (
finalAttrs:
args
// {
nativeBuildInputs = [ mdbook ];

dontPatch = true;
dontConfigure = true;
doCheck = false;

buildPhase = ''
runHook preBuild
ln -s ${nixosDoc} src/options/nixos-options.md
ln -s ${homeManagerDoc} src/options/home-manager-options.md
mdbook build
runHook postBuild
'';

installPhase = ''
runHook preInstall
mv book $out
runHook postInstall
'';

passthru = {
serve = writeShellApplication {
name = "serve";

runtimeInputs = [ python3 ];

text = ''
python -m http.server --bind 127.0.0.1 --directory ${finalAttrs.finalPackage}
'';
};
};
};
})
}
)
55 changes: 26 additions & 29 deletions docs/options-doc.nix
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
{ lib
, nixosOptionsDoc
,
}: { version
, modules
,
}:
(
nixosOptionsDoc {
options =
builtins.removeAttrs
(
lib.evalModules {
modules = modules ++ [{
options.system.nixos.release = lib.mkOption {
type = lib.types.str;
default = lib.trivial.release;
readOnly = true;
};
{ lib, nixosOptionsDoc }:
{ version, modules }:
(nixosOptionsDoc {
options =
builtins.removeAttrs
(lib.evalModules {
modules = modules ++ [
{
options.system.nixos.release = lib.mkOption {
type = lib.types.str;
default = lib.trivial.release;
readOnly = true;
};

config = {
_module.check = false;
};
}];
config = {
_module.check = false;
};
}
).options [ "_module" "system" ];
];
}).options
[
"_module"
"system"
];

transformOptions = opt: builtins.removeAttrs opt [ "declarations" ];
transformOptions = opt: builtins.removeAttrs opt [ "declarations" ];

documentType = "none";
revision = version;
}
).optionsCommonMark
documentType = "none";
revision = version;
}).optionsCommonMark
8 changes: 2 additions & 6 deletions modules/home-manager/alacritty.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{ config
, lib
, ...
}:
{ config, lib, ... }:
let
inherit (lib) ctp;
inherit (config.catppuccin) sources;
cfg = config.programs.alacritty.catppuccin;
enable = cfg.enable && config.programs.alacritty.enable;
in
{
options.programs.alacritty.catppuccin =
ctp.mkCatppuccinOpt "alacritty";
options.programs.alacritty.catppuccin = ctp.mkCatppuccinOpt "alacritty";

config = lib.mkIf enable {
programs.alacritty.settings = lib.importTOML "${sources.alacritty}/catppuccin-${cfg.flavour}.toml";
Expand Down
8 changes: 2 additions & 6 deletions modules/home-manager/bat.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
{ config
, lib
, ...
}:
{ config, lib, ... }:
let
inherit (config.catppuccin) sources;
cfg = config.programs.bat.catppuccin;
enable = cfg.enable && config.programs.bat.enable;
themeName = "Catppuccin ${lib.ctp.mkUpper cfg.flavour}";
in
{
options.programs.bat.catppuccin =
lib.ctp.mkCatppuccinOpt "bat";
options.programs.bat.catppuccin = lib.ctp.mkCatppuccinOpt "bat";

config = lib.mkIf enable {
programs.bat = {
Expand Down
Loading

0 comments on commit 5e1a679

Please sign in to comment.