-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf85308
commit 5e938eb
Showing
2 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
description = "My flake with dream2nix packages"; | ||
|
||
inputs = { | ||
dream2nix.url = "github:nix-community/dream2nix"; | ||
nixpkgs.follows = "dream2nix/nixpkgs"; | ||
}; | ||
|
||
outputs = inputs @ { | ||
self, | ||
dream2nix, | ||
nixpkgs, | ||
... | ||
}: let | ||
system = "x86_64-linux"; | ||
in { | ||
# all packages defined inside ./packages/ | ||
packages.${system}.default = nixpkgs.lib.evalModules { | ||
modules = []; | ||
|
||
projectRoot = ./.; | ||
# can be changed to ".git" or "flake.nix" to get rid of .project-root | ||
projectRootFile = "flake.nix"; | ||
packagesDir = ./packages; | ||
packageSets.nixpkgs = nixpkgs.legacyPackages.${system}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,272 @@ | ||
{ | ||
pkgs ? import <nixpkgs> {}, | ||
lib ? import <nixpkgs/lib>, | ||
... | ||
}: let | ||
findCycles = import ../../../lib/internal/findCycles.nix {inherit lib;}; | ||
in { | ||
test_simple = { | ||
expr = findCycles { | ||
dependencyGraph = { | ||
a.v1 = [ | ||
{ | ||
name = "b"; | ||
version = "v1"; | ||
} | ||
]; | ||
b.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
roots = { | ||
a = "v1"; | ||
}; | ||
}; | ||
expected = { | ||
b.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
test_cycle_length_3 = { | ||
expr = findCycles { | ||
dependencyGraph = { | ||
a.v1 = [ | ||
{ | ||
name = "b"; | ||
version = "v1"; | ||
} | ||
]; | ||
b.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
c.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
roots = { | ||
a = "v1"; | ||
}; | ||
}; | ||
expected = { | ||
c.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
test_two_roots_both_chosen = { | ||
expr = findCycles { | ||
dependencyGraph = { | ||
a.v1 = [ | ||
{ | ||
name = "b"; | ||
version = "v1"; | ||
} | ||
]; | ||
b.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
c.v1 = [ | ||
{ | ||
name = "d"; | ||
version = "v1"; | ||
} | ||
]; | ||
d.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
roots = { | ||
a = "v1"; | ||
c = "v1"; | ||
}; | ||
}; | ||
expected = { | ||
b.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
d.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
test_two_roots_one_chosen = { | ||
expr = findCycles { | ||
dependencyGraph = { | ||
a.v1 = [ | ||
{ | ||
name = "b"; | ||
version = "v1"; | ||
} | ||
]; | ||
b.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
c.v1 = [ | ||
{ | ||
name = "d"; | ||
version = "v1"; | ||
} | ||
]; | ||
d.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
roots = { | ||
a = "v1"; | ||
}; | ||
}; | ||
expected = { | ||
b.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
test_c_visited_twice_no_cycle = { | ||
expr = findCycles { | ||
dependencyGraph = { | ||
a.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
b.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
c.v1 = []; | ||
}; | ||
roots = { | ||
a = "v1"; | ||
b = "v1"; | ||
}; | ||
}; | ||
expected = {}; | ||
}; | ||
|
||
test_two_cycles_one_root = { | ||
expr = findCycles { | ||
dependencyGraph = { | ||
a.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
b.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
c.v1 = [ | ||
{ | ||
name = "d"; | ||
version = "v1"; | ||
} | ||
]; | ||
d.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
{ | ||
name = "b"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
roots = { | ||
a = "v1"; | ||
}; | ||
}; | ||
expected = { | ||
d.v1 = [ | ||
{ | ||
name = "a"; | ||
version = "v1"; | ||
} | ||
]; | ||
b.v1 = [ | ||
{ | ||
name = "c"; | ||
version = "v1"; | ||
} | ||
]; | ||
}; | ||
}; | ||
|
||
# TODO: fix the implementation to remove furthest edges from the root only | ||
# test_two_cycles_two_roots = { | ||
# expr = findCycles { | ||
# dependencyGraph = { | ||
# a.v1 = [ | ||
# {name = "c"; version = "v1";} | ||
# ]; | ||
# b.v1 = [ | ||
# {name = "c"; version = "v1";} | ||
# ]; | ||
# c.v1 = [ | ||
# {name = "d"; version = "v1";} | ||
# ]; | ||
# d.v1 = [ | ||
# {name = "a"; version = "v1";} | ||
# {name = "b"; version = "v1";} | ||
# ]; | ||
# }; | ||
# roots = { | ||
# a = "v1"; | ||
# b = "v1"; | ||
# }; | ||
# }; | ||
# expected = { | ||
# d.v1 = [ | ||
# {name = "a"; version = "v1";} | ||
# {name = "b"; version = "v1";} | ||
# ]; | ||
# }; | ||
# }; | ||
} |